Skip to content
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

skip_duplicates ignores weight #35836

Closed
nurey opened this issue Nov 22, 2018 · 1 comment · Fixed by #36996
Closed

skip_duplicates ignores weight #35836

nurey opened this issue Nov 22, 2018 · 1 comment · Fixed by #36996
Labels
>bug :Search Relevance/Suggesters "Did you mean" and suggestions as you type Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch

Comments

@nurey
Copy link

nurey commented Nov 22, 2018

Elasticsearch version (bin/elasticsearch --version): 6.5.1, Build: default/tar/8c58350/2018-11-16T02:22:42.182257Z, JVM: 11.0.1

Plugins installed:
ingest-geoip
ingest-user-agent

JVM version (java -version):
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)

OS version (uname -a if on a Unix-like system):
Linux 1f3aa3980dfa 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:

Running a suggest query with skip_duplicates set to true ignores weight of documents.

Steps to reproduce:

Create mapping:

PUT /listing_address
{
  "mappings": {
    "listing": {
      "properties": {
        "suggest": {
          "type": "completion",
          "analyzer": "standard",
          "contexts": [
          	{
          		"name": "status_and_rental",
          		"type": "category"
          	}
          ]
        }
      }
    }
  }
}

Index some documents:

PUT /listing_address/listing/123123123
{
"suggest": {
    "contexts": {
        "status_and_rental": "U"
    },
    "input": [
        "502-30 Church St, Toronto, ON, M5E1S7",
        "30 Church St Toronto ON M5E1S7"
    ],
    "weight": 662
}
}

PUT /listing_address/listing/123123124
{
"suggest": {
    "contexts": {
        "status_and_rental": "UR"
    },
    "input": [
        "502-30 Church St, Toronto, ON, M5E1S7",
        "30 Church St Toronto ON M5E1S7"
    ],
    "weight": 710
}
}

PUT /listing_address/listing/123123125
{
"suggest": {
    "contexts": {
        "status_and_rental": "U"
    },
    "input": [
        "502-30 Church St, Toronto, ON, M5E1S7",
        "30 Church St Toronto ON M5E1S7"
    ],
    "weight": 1228
}
}

"status_and_rental" varies from document to document with possible values of "U" or "UR". Weight varies between 662 and 1228.

Here's my search query:

POST /listing_address/_search?pretty
{
  "suggest": {
	 "address-suggest": {
    	"prefix": "502-30 church",
		"completion": {
			"field": "suggest",
			"size": 99,
			"skip_duplicates": true,
			"contexts": {
				"status_and_rental": ["UR", "U"]
			}
		}
      }
  }
}

The query returns one document with the weight of 662. But there are other documents with higher weight. I would expect the document with the highest weight to be returned.

@jimczi jimczi added >bug :Search Relevance/Suggesters "Did you mean" and suggestions as you type labels Nov 22, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

jimczi added a commit that referenced this issue Jan 15, 2019
The completion suggester ignores the original weight of the suggestion when duplicates are removed. This change fixes this bug and keeps the best weighted suggestion among the duplicates. It also removes the custom implementation of the top docs suggest collector now that https://issues.apache.org/jira/browse/LUCENE-8529 is committed in Lucene.

Closes #35836
jimczi added a commit that referenced this issue Jan 30, 2019
The completion suggester ignores the original weight of the suggestion when duplicates are removed. This change fixes this bug and keeps the best weighted suggestion among the duplicates. It also removes the custom implementation of the top docs suggest collector now that https://issues.apache.org/jira/browse/LUCENE-8529 is committed in Lucene.

Closes #35836
@javanna javanna added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search Relevance/Suggesters "Did you mean" and suggestions as you type Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants