[hibernate-dev] [AND] Search: changing the way we search
emmanuel at hibernate.org
Tue Mar 4 07:36:51 EST 2014
On 04 Mar 2014, at 12:24, Guillaume Smet <guillaume.smet at gmail.com> wrote:
> Hi Emmanuel,
> On Tue, Mar 4, 2014 at 11:09 AM, Emmanuel Bernard
> <emmanuel at hibernate.org> wrote:
>> If I understand you, you wan to find several and words and in and my and content in title or in summary or in content but all terms should be present in one of the field. Is that correct? What's the use case behind?
> It's probably the most common use case we have.
> Let's say you have an entity called "Hotel whatever" and in its
> description it says it does have a swimming pool but the word "hotel"
> doesn't appear in the description (my example isn't the best chosen
> but I think you can easily imagine it does happen on real data).
> Our user is looking for "hotel swimming pool", and we want "Hotel
> whatever" to match.
OK so you want the words hotel + swimming pool to be present somewhere in the sum of the corpus of title and description. That’s the second case I was describing then. Indeed it kinda fails if you don’t order by score but rather alphabetically or by distance.
Have you considered the following: your query should only consider the top n, or the results whose score reaches 70% of the top score and then do your business sort on this subset.
Anyways, to address this, one need to target fields that are:
- using the same fieldbridge
- using the same analyzer
- do the trick I was describing around filters like ngrams (and then or)
More information about the hibernate-dev