Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capability to search in nested arrays of objects #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ziaulrehman40
Copy link

{
  isbn: '9781597226769',
  title: 'The Great Gatsby',
  authors: [
    {
        name: 'F. Scott Fitzgerald'
    },
    {
        name: 'James D'
    }
  ],
  tags: ['book', 'inspirational']
}

Allows to search in deeply nested arrays with syntax suggested in #47 , i.e: ['authors', '[]', 'name'] for above example.

Solves #47 and #77 .

PS: If there is anything we can improve in this PR, i am happy to do that. One thing i know is that I could probably make change in existing getNestedFieldValue function instead of making a new getNestedFieldValues function. But that seemed to have far more consequences and we needed this support ASAP.

@gaberger
Copy link

Is there a reason the nested search is not upstreamed to master?

@BurnNoticeSpy
Copy link

Can this please be merged????!!! How can i use this fix in the mean time? I don't know what to do to update from the original package...

@BurnNoticeSpy
Copy link

BurnNoticeSpy commented May 1, 2021

Got it installed. Thanks @ziaulrehman40.

Is there a way of returning the data closer to the match? I have a large and complex set of json to work with that has many levels of array nestings, and when a match is currently found, it returns data too far up and i don't know where it came from.

@ziaulrehman40
Copy link
Author

@BurnNoticeSpy Good to know you got it working.
But its been years on this, i don't recall properly, you will have to dig a bit i guess.

@Pushparaj2021
Copy link

HI @ziaulrehman40, @BurnNoticeSpy , @bvaughn ,

I am not able to search for a nested array of Objects, Tried @ziaulrehman40 approach with no success.

authors: [
{
name: 'F. Scott Fitzgerald',
age: 20,
},
{
name: 'James D',
age: 21,
}
],

search.addIndex(['authors','[]','name'])

request your help to get this resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants