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

Disable cross-matches on multi-valued fields [LUCENE-3322] #4395

Open
asfimport opened this issue Jul 15, 2011 · 1 comment
Open

Disable cross-matches on multi-valued fields [LUCENE-3322] #4395

asfimport opened this issue Jul 15, 2011 · 1 comment

Comments

@asfimport
Copy link

When searching against a multi-valued field it is often advantageous to disable cross-matches. For instance, if a book contains two authors: "john smith" and "brian jones", a search for "john jones" should not match.

Currently the best workaround is to search using a sloppy phrase query. The drawback is that phrases are incompatible with other features such as wildcards and ranges. Additionally, it is left up to the user to know to formulate the query differently if searching a multi-valued field.


Migrated from LUCENE-3322 by James Dyer (@jdyer1)
Attachments: LUCENE-3322.patch

@asfimport
Copy link
Author

asfimport commented Jul 15, 2011

James Dyer (@jdyer1) (migrated from JIRA)

Here is an initial patch. Creating this was an adventure for me in learning some of Lucene's internals!

In this approach, ConjunctionScorer verifies that all of the matches' positions fall within the range of a user-supplied positionIncrementGap. Supported query types are: TermQuery, TermRangeQuery, PrefixQuery, PhraseQuery, WidlcardQuery, FuzzyQuery & BooleanQuery. A unit test is included demonstrating use with each of these query types.

All unit tests pass. However, there are some glaring inefficiencies in this initial impl attempt. Perhaps #3952 will ultimately provide much of the functionality otherwise implemented here (??). Also, should #3384 be implemented, there might be an opportunity to store a Field Type's PositionIncrementGap in the index, further lessening the burden on the user to correctly issue these types of queries.

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

1 participant