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

Native plugin script under nested #25

Open
himanshuB2 opened this issue Oct 4, 2016 · 2 comments
Open

Native plugin script under nested #25

himanshuB2 opened this issue Oct 4, 2016 · 2 comments

Comments

@himanshuB2
Copy link

Hi imotov,

I went through your examples, but wasn't able to find one where you use a script for a nested document under 'nested'. The challenge I am facing there is that the source()/doc() fetch gives me 0 results even though I do expect matches. I believe that may have to do with nested documents being stored as a separate document, but I am not sure.

Would appreciate any help! Thanks for writing up all these examples! :)

@imotov
Copy link
Owner

imotov commented Oct 4, 2016

Dealing with nested documents is tricky. The problem is nested documents are indexed as separate documents, they can be only searched by nested queries and they don't participate in the fetching of documents since they don't contain source (nested documents are used to find their parent document and then source is retrieved from the parent document). What are you trying to do with nested documents from the script? What context do you run this script from?

@himanshuB2
Copy link
Author

himanshuB2 commented Oct 4, 2016

Thanks for the super quick response.

I am trying to perform operations (add a filter) on fields stored as analyzed. These operations need to occur on the entire string, context of which is lost in the index unless this is indexed in a multifield index. Due to cost constraints (ie use case not justifying cost of redundant storage), we are left with going only for index as analyzed. So, I am using the script to fetch the field from source (as the last filter) to filter out unwanted results. The field could be nested or non nested. We haven't yet evaluated the performance impact of this approach just yet.

That being said, the approach of finding parent to extract source sounds interesting. I may be missing something, but all I care about in my script is the value of the nested field only. To clarify, I don't need the entire parent source if that can be avoided, just the nested document field value. Would be great if you could point me to the relevant classes/methods that I could look into for either of the two approaches.

Thanks!

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

No branches or pull requests

2 participants