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

Merged
merged 3 commits into from Jun 26, 2018

Conversation

3 participants
@safwanrahman
Member

safwanrahman commented Jun 22, 2018

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 and OR operator. AND operator has higher priority than the OR operator.
Like search with Foo Bar(without quote) will match all the documents which have either Foo or Bar, but the pages which have Foo and Bar 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?

@safwanrahman safwanrahman requested a review from ericholscher Jun 22, 2018

@safwanrahman safwanrahman self-assigned this Jun 22, 2018

@safwanrahman safwanrahman added this to Backlog in Search update via automation Jun 22, 2018

@safwanrahman safwanrahman moved this from Backlog to In progress in Search update Jun 22, 2018

@davidfischer

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):

This comment has been minimized.

@davidfischer

davidfischer Jun 22, 2018

Contributor

This doesn't appear to be used. Is it necessary?

This comment has been minimized.

@safwanrahman

safwanrahman Jun 23, 2018

Member

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

This comment has been minimized.

@davidfischer

davidfischer Jun 22, 2018

Contributor

Is the thought process that the first example -- both "foo" and "bar" are present -- will rank more highly than the second?

This comment has been minimized.

@safwanrahman

safwanrahman Jun 23, 2018

Member

Yes. It will have higher in rank as its more relevant

@ericholscher

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']:

This comment has been minimized.

@ericholscher

ericholscher Jun 25, 2018

Member

Do we need to boost the AND in some way, or will it automatically sort higher?

This comment has been minimized.

@safwanrahman

safwanrahman Jun 25, 2018

Member

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!

This comment has been minimized.

@ericholscher

ericholscher Jun 26, 2018

Member

Let's leave it for now, and we can boost it later if we want.

@ericholscher ericholscher merged commit af641b0 into rtfd:search_upgrade Jun 26, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

Search update automation moved this from In progress to Done Jun 26, 2018

@safwanrahman safwanrahman deleted the safwanrahman:exact_match branch Jul 7, 2018

safwanrahman added a commit to safwanrahman/readthedocs.org that referenced this pull request Jul 16, 2018

safwanrahman added a commit to safwanrahman/readthedocs.org that referenced this pull request Jul 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment