Closed rowandh closed 8 years ago
Missed some test cases in my initial PR. Somehow skipped over the fact that this affects all queries and not just queries where DefaultSearchProperty is set. I'll create another one.
Merged to master.
This was released in 3.6.0 today on nuget.org.
Several type of Lucene queries are parsed incorrectly by FieldMappingQueryParser:
To reproduce:
This is due to the search field only being overridden with DefaultSearchProperty on certain QueryParser overrides:
but not:
Solution: We could override these methods and use them to remap the default search field. But this beholds us to any changes in the internals of QueryParser.
The correct solution is to inject the default search field to FieldMappingQueryParser's constructor rather than set it as a property.
Then we can add an override CreateQueryParser(string defaultField) to LuceneDataProvider, and remove the DefaultSearchProperty property from FieldMappingQueryParser.
I don't see any advantage to using a property to set this field - if a user wants to dynamically change the default search field for some reason, they can just use the factory method to create a new query parser.
However, this fix breaks backwards compatibility for anyone who is already using DefaultSearchProperty (although many of their queries will already be returning no results).
There is an interim solution:
I'm not sure how keen you are to introduce a change that breaks backwards compatibility, so I'll submit a PR shortly with my interim solution and tests.