Elasticsearch highlight field is missing in percolate query result if the field is of type ‘ip’

Using elasticsearch 6.2.4

I have a simple percolator index setup with 2 fields ip_address and title. ip_address has the type ip and title has the type text.

Percolator Mapping

{
    "my-percolator-index": {
        "mappings": {
            "_doc": {
                "dynamic": "true",
                "properties": {
                    "query": {
                        "type": "percolator"
                    },
                    "ip_address": {
                        "type": "ip"
                    },
                    "title": {
                        "type": "text"
                    }
                }
            }
        }
    }
}

Added a percolate query to the index with CIDR range

{
    "_index": "my-percolator-index",
    "_type": "_doc",
    "_id": "123456789",
    "_version": 1,
    "found": true,
    "_source": {
        "query": {
            "bool": {
                "must": {
                    "simple_query_string": {
                        "query": "192.168.0.0/16",
                        "fields": [
                            "ip_address"
                        ],
                        "default_operator": "AND"
                    }
                }
            }
        }
    }
}

Made a _search request to the index

{
  "url": "http://localhost:9200/my-percolator-index/_search",
  "auth": [
    "<username>",
    "<password>"
  ],
  "json": {
    "size": 200,
    "query": {
      "percolate": {
        "field": "query",
        "documents": [
          {
            "body": {
              "ip_address": "192.168.1.1",
              "title": "This is a test title"
            }
          }
        ]
      }
    },
    "highlight": {
      "fields": {
        "ip_address": {
          "pre_tags": "<hl>",
          "post_tags": "</hl>"
        }
      },
      "fragment_size": 250
    },
    "timeout": "10s"
  },
  "timeout": 15,
  "verify": false
}

Got back a result that hit on the original percolate query.

{
  "took": 162,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1.0,
    "hits": [
      {
        "_index": "my-percolator-index",
        "_type": "_doc",
        "_id": "123456789",
        "_score": 1.0,
        "_source": {
          "query": {
            "bool": {
              "must": {
                "simple_query_string": {
                  "query": "192.168.0.0/16",
                  "fields": [
                    "ip_address"
                  ],
                  "default_operator": "AND"
                }
              }
            }
          }
        },
        "fields": {
          "_percolator_document_slot": [
            0
          ]
        }
      }
    ]
  }
}

However, there's no highlight that came back. If I tested it with the title attribute and matched it with text, the highlight will come back.

Is there an issue with ip type for highlighting?



Read more here: https://stackoverflow.com/questions/66448205/elasticsearch-highlight-field-is-missing-in-percolate-query-result-if-the-field

Content Attribution

This content was originally published by Charlie Ou Yang at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: