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

no highlights with a highlight prefix query and FVH when no match found #25171

Closed
v1r opened this issue Jun 10, 2017 · 1 comment · Fixed by #25197
Closed

no highlights with a highlight prefix query and FVH when no match found #25171

v1r opened this issue Jun 10, 2017 · 1 comment · Fixed by #25197
Assignees
Labels
>bug :Search Relevance/Highlighting How a query matched a document Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch

Comments

@v1r
Copy link

v1r commented Jun 10, 2017

Following this issue: #25088

Elasticsearch version: 5.4.0 and 5.4.1
JVM version: 1.8
OS version : Windows 7

No highlights returned using a prefix in a highlight_query when a document attribute has an empty value or no match found

Steps to reproduce:

Create the following index

PUT foo
{
  "mappings": {
    "blogpost": { 
      "properties": { 
        "title": { "type": "text", "term_vector": "with_positions_offsets"}, 
        "description":  { "type": "text", "term_vector": "with_positions_offsets"  }
      }
    }
  }
}

Add a new document, notice description is empty (no match for 'sq' string).

PUT foo/entry/1
{
  "title": "SQ05_H04_WorldTour test",
  "description": ""
}

Run the following query to highlight the string containing 'sq'.

GET foo/_search
{
   "query":{
      "match_all":{ }
   },
   "highlight":{
      "fields":{
         "title":{
            "number_of_fragments":10,
            "type":"fvh",
            "highlight_query":{
               "prefix":{
                  "title":"sq"
               }
            }
         },
         "description":{
            "number_of_fragments":10,
            "type":"fvh",
            "highlight_query":{
               "prefix":{
                  "description":"sq"
               }
            }
         }
      },
      "require_field_match":false
   }
}

The result as expected highlights the string containing 'sq'

{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "foo",
        "_type": "entry",
        "_id": "1",
        "_score": 1,
        "_source": {
          "title": "SQ05_H04_WorldTour test",
          "description": ""
        },
        "highlight": {
          "title": [
            "<em>SQ05_H04_WorldTour</em> test"
          ]
        }
      }
    ]
  }
}

Lets re-execute the same query, but this time we change the order of fields..

GET foo/_search
{
   "query":{
      "match_all":{ }
   },
   "highlight":{
      "fields":{
         "description":{
            "number_of_fragments":10,
            "type":"fvh",
            "highlight_query":{
               "prefix":{
                  "description":"sq"
               }
            }
         },
         "title":{
            "number_of_fragments":10,
            "type":"fvh",
            "highlight_query":{
               "prefix":{
                  "title":"sq"
               }
            }
         }
      },
      "require_field_match":false
   }
}

Surprisingly, no highlighs returned..

{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "foo",
        "_type": "entry",
        "_id": "1",
        "_score": 1,
        "_source": {
          "title": "SQ05_H04_WorldTour test",
          "description": ""
        }
      }
    ]
  }
}

is this is a bug? same behavior in 2.x

@v1r v1r changed the title no highlights with a highlight prefix query and FVH when a document attribute as an empty value no highlights with a highlight prefix query and FVH when no match found Jun 10, 2017
@clintongormley clintongormley added :Search Relevance/Highlighting How a query matched a document >bug labels Jun 12, 2017
@v1r
Copy link
Author

v1r commented Jun 12, 2017

This is also true for multi terms query like wildcard, regexp

jimczi added a commit to jimczi/elasticsearch that referenced this issue Jun 13, 2017
This commit removes the global caching of the field query and replaces it with
a caching per field. Each field can use a different `highlight_query` and the rewriting of
some queries (prefix, automaton, ...) depends on the targeted field so the query used for highlighting
must be unique per field.
There might be a small performance penalty when highlighting multiple fields since the query needs to be rewritten
once per highlighted field with this change.

Fixes elastic#25171
jimczi added a commit that referenced this issue Jun 14, 2017
This commit removes the global caching of the field query and replaces it with
a caching per field. Each field can use a different `highlight_query` and the rewriting of
some queries (prefix, automaton, ...) depends on the targeted field so the query used for highlighting
must be unique per field.
There might be a small performance penalty when highlighting multiple fields since the query needs to be rewritten
once per highlighted field with this change.

Fixes #25171
@javanna javanna added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search Relevance/Highlighting How a query matched a document 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