Skip to content

FVH (fast vector highlighter) does not highlight subfields that was indexed from array. #75011

Closed
@azarkevich

Description

@azarkevich

Docker image
docker.elastic.co/elasticsearch/elasticsearch:7.13.2

Elasticsearch version (bin/elasticsearch --version):
Version: 7.13.2, Build: default/docker/4d960a0733be83dd2543ca018aa4ddc42e956800/2021-06-10T21:01:55.251515791Z, JVM: 16

Plugins installed: []

JVM version (java -version):

openjdk 16 2021-03-16
OpenJDK Runtime Environment AdoptOpenJDK (build 16+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 16+36, mixed mode, sharing)

OS version (uname -a if on a Unix-like system):
Linux bf00e93afa1f 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:
FVH (fast vector highlighter) does not highlight subfields that was indexed from array.

Steps to reproduce:

# create index and mappings for text field and subfield: prop1 and prop1.fld1
curl -XPUT "http://elastic:9200/test"
curl -XPUT "http://elastic:9200/test/_mapping" -H 'Content-Type: application/json' -d'
{
  "properties": {
    "prop1": {
      "type": "text",
      "analyzer": "english",
      "index_options": "offsets",
      "term_vector": "with_positions_offsets",
      "fields": {
        "fld1": {
          "type": "text",
          "analyzer": "english",
          "index_options": "offsets",
          "term_vector": "with_positions_offsets"
        }
      }
    }
  }
}'

# add two documents with property prop1 as string and as array
curl -XPUT "http://elastic:9200/test/_doc/1" -H 'Content-Type: application/json' -d'
{
  "prop1": "foo bar baz"
}'
curl -XPUT "http://elastic:9200/test/_doc/2" -H 'Content-Type: application/json' -d'
{
  "prop1": [ "foo bar baz" ]
}'

# perform search and highlight on all fields/subfields
curl -XGET "http://elastic:9200/test/_search" -H 'Content-Type: application/json' -d'
{
  "query": {
    "simple_query_string": {
      "query": "bar"
    }
  },
  "highlight": {
    "type": "fvh",
    "fields": {
      "*": {}
    }
  }
}'

I expect that both documents will be found, each with 2 highlighted fields:

...
"highlight" : {
  "prop1" : [
	"foo <em>bar</em> baz"
  ],
  "prop1.fld1" : [
	"foo <em>bar</em> baz"
  ]
}
...

But document 2 returned with only prop1 highlighted:

...
"highlight" : {
  "prop1" : [
    "foo <em>bar</em> baz"
  ]
}
...

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