Relaxed phrase Search

Anyone in this community tried implementing relaxed phrase search as explained in below example -

d1- "Hi, this is Imran from Microsoft"
d2 - "Microsoft is where the employee named Imran works"

Say in above texts I want to perform a search like this -

Query: Imran BEFORE/2 Microsoft
Meaning of the query - Search for sentences where we have Imran and Microsoft and the maximum words allowed between them is 2.
Result: d1

Another example -

Query: Imran AFTER/7 Microsoft
Meaning of the query - Search for sentences where we have Imran and Microsoft and the maximum words allowed between them is 2.
Result: d2

I can share more examples if needed
Thanks
Imran

Have a look at using a phrase query with the slop parameter. Using a large value for slop may end up returning lots of false positives though.

1 Like

Sounds great - https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.