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

Discrepancy in Search Results with spanNearQuery #14056

Open
ani8570 opened this issue Dec 11, 2024 · 2 comments
Open

Discrepancy in Search Results with spanNearQuery #14056

ani8570 opened this issue Dec 11, 2024 · 2 comments

Comments

@ani8570
Copy link

ani8570 commented Dec 11, 2024

Description

Hello,
I'm contacting you to confirm a discrepancy I've found while using SpanNearQuery.

  1. When searching for "applepie bananapie", it doesn't find results in files indexed as "apple pie banana pie"
  2. When analyzing "applepie bananapie":
    apple:PositionIncrementAttribute.setPositionIncrement(1)
    pie:PositionIncrementAttribute.setPositionIncrement(0)
    banana:PositionIncrementAttribute.setPositionIncrement(1)
    pie:PositionIncrementAttribute.setPositionIncrement(0)
    Then searching with inorder spanNear(apple, pie, banana, pie)
  3. Expected normal search results for all values below the default of 21
  4. No results output
  5. Debugging results show:
@Override public int endPosition() { 
return (position == -1) ? -1 : (position != NO_MORE_POSITIONS) ? position + 1 : NO_MORE_POSITIONS; 
}

The search stops due to position + 1, resulting in no search results

I'm wondering if there's a special reason for including position + 1. If not, it seems it would be better to remove the "+1" part.

@ludicrousdisplay
Copy link

My understanding of the SpanQuery API is that in the example you provide it will be looking for exact matches of the "applepie" token next to the "bananapie" token. Therefore the separate tokens "apple" and "pie" will not match the first query term "applepie".

Since span queries can be nested you could break each search term "applepie" and "bananapie" into a pair of tokens ("apple", "pie) and create each as a SpanNearQuery, then combine them into another one.

@ani8570
Copy link
Author

ani8570 commented Dec 11, 2024

Hello,

Previously, we attempted the following searches:

  1. applepie bananapie

  2. apple pie banana pie

using inorder spanNear(apple pie banana pie), but document 1 was not retrieved.

In document 1, for applepie,

apple has posIncre:1

pie has posIncre:0

This lack of position increment prevents it from being retrieved.

Even searching with spanNear(apple,pie) and spanNear(banana,pie) yields no results.

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

No branches or pull requests

2 participants