Skip to content

Percolate query, FVH highlighter does not work on subfields #82458

Closed
@buinauskas

Description

@buinauskas

Elasticsearch version (bin/elasticsearch --version): 7.16.2

Plugins installed: []

JVM version (java -version):

OS version (uname -a if on a Unix-like system):

Description of the problem including expected versus actual behavior:

Percolated queries no longer highlight subfields with FVH higlighter. I expect them to be highlighted as in the previous version of ES.

Steps to reproduce:
Index mappings with a field and subfield with identical analysis, both have term vectors with positions offsets.

PUT /test
{
  "mappings": {
    "properties": {
      "query": {
        "type": "percolator"
      },
      "userinput": {
        "type": "text",
        "analyzer": "standard",
        "term_vector": "with_positions_offsets",
        "fields": {
          "another": {
            "type": "text",
            "analyzer": "standard",
            "term_vector": "with_positions_offsets"
          }
        }
      }
    }
  }
}

A couple of test documents:

PUT /test/_doc/1?refresh=true
{
  "query": {
    "match_phrase": {
      "userinput": {
        "query": "kimchi"
      }
    }
  }
}

PUT /test/_doc/2?refresh=true
{
  "query": {
    "match_phrase": {
      "userinput.another": {
        "query": "kimchi"
      }
    }
  }
}

The actual search query:

GET /test/_search
{
  "query": {
    "percolate": {
      "field": "query",
      "document": {
        "userinput": "kimchi"
      }
    }
  },
  "highlight": {
    "type": "fvh",
    "fields": {
      "*": {}
    }
  }
}

This sequence would respond with the following on 7.16.2, notice that the second document contains no highlighting.

{
  "took": 3,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 2,
      "relation": "eq"
    },
    "max_score": 0.13076457,
    "hits": [
      {
        "_index": "test",
        "_type": "_doc",
        "_id": "1",
        "_score": 0.13076457,
        "_source": {
          "query": {
            "match_phrase": {
              "userinput": {
                "query": "kimchi"
              }
            }
          }
        },
        "fields": {
          "_percolator_document_slot": [0]
        },
        "highlight": {
          "userinput": ["<em>kimchi</em>"]
        }
      },
      {
        "_index": "test",
        "_type": "_doc",
        "_id": "2",
        "_score": 0.13076457,
        "_source": {
          "query": {
            "match_phrase": {
              "userinput.another": {
                "query": "kimchi"
              }
            }
          }
        },
        "fields": {
          "_percolator_document_slot": [0]
        }
      }
    ]
  }
}

Executing the same sequence on 7.9.3 highlights both of the results:

{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 2,
      "relation": "eq"
    },
    "max_score": 0.13076457,
    "hits": [
      {
        "_index": "test",
        "_type": "_doc",
        "_id": "1",
        "_score": 0.13076457,
        "_source": {
          "query": {
            "match_phrase": {
              "userinput": {
                "query": "kimchi"
              }
            }
          }
        },
        "fields": {
          "_percolator_document_slot": [0]
        },
        "highlight": {
          "userinput": ["<em>kimchi</em>"]
        }
      },
      {
        "_index": "test",
        "_type": "_doc",
        "_id": "2",
        "_score": 0.13076457,
        "_source": {
          "query": {
            "match_phrase": {
              "userinput.another": {
                "query": "kimchi"
              }
            }
          }
        },
        "fields": {
          "_percolator_document_slot": [0]
        },
        "highlight": {
          "userinput.another": ["<em>kimchi</em>"]
        }
      }
    ]
  }
}

Provide logs (if relevant):

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions