-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[Fix #2457] Implement exact match search #4292
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
[Fix #2457] Implement exact match search #4292
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still trying to grasp everything there is to know about our search but I had a few comments/questions on this one.
@@ -20,7 +20,7 @@ def es_index(): | |||
|
|||
|
|||
@pytest.fixture(autouse=True) | |||
def all_projects(es_index, mock_processed_json): | |||
def all_projects(es_index, mock_processed_json, db): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't appear to be used. Is it necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its actually a fixture which need to injected for db access. whether you use or not, if any fixture has dependency to db
fixture, that means the fixture has access to database.
If query is `Foo Bar` then the result should be as following order: | ||
|
||
- Where both `Foo Bar` is present | ||
- Where `Foo` or `Bar` is present |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the thought process that the first example -- both "foo" and "bar" are present -- will rank more highly than the second?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It will have higher in rank as its more relevant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. I'm excited about the addition of SimpleQueryString
, as I think that will make our searches much nicer in general.
|
||
# Need to search for both 'AND' and 'OR' operations | ||
# The score of AND should be higher as it comes first | ||
for operator in ['AND', 'OR']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to boost the AND
in some way, or will it automatically sort higher?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AND
matched index will surely have higher score as it satisfies both of the query.
It describes better: https://www.elastic.co/guide/en/elasticsearch/guide/current/bool-query.html#CO60-1
Or we can add boost
value to the query explecitly!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave it for now, and we can boost it later if we want.
[Fix readthedocs#2457] Implement exact match search
[Fix readthedocs#2457] Implement exact match search
Fix #2457
This PR implements searching exact phrase by using
""
quoted text.(eg:"foo bar"
)It also rewrite the search functionality as there will be more relavant result by using both
AND
andOR
operator.AND
operator has higher priority than theOR
operator.Like search with
Foo Bar
(without quote) will match all the documents which have eitherFoo
orBar
, but the pages which haveFoo
andBar
both, will be higher in index. So user will first see the relavant results, then see other results wich maybe also helpful for them.I have used bool query to combine both of the query. Elasticsearch The Definative Guide helped mostly to understand the thing. The paragraph in
elasticsearch-dsl
docs is also helpful.@ericholscher r?