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

Highlight tags not working with Percolator - Unified Highlighter #24224

Closed
gmoskovicz opened this issue Apr 20, 2017 · 1 comment
Closed

Highlight tags not working with Percolator - Unified Highlighter #24224

gmoskovicz opened this issue Apr 20, 2017 · 1 comment
Assignees
Labels
>bug :Search/Highlighting How a query matched a document

Comments

@gmoskovicz
Copy link
Contributor

Elasticsearch version: 5.3.0

Plugins installed: [x-pack]

JVM version: All

OS version: Mac

Description of the problem including expected versus actual behavior:

Steps to reproduce:

[1] Create a test index

DELETE test

PUT test
{
  "settings": {
    "analysis": {
      "normalizer": {
        "lowercase_normalizer": {
          "type": "custom",
          "filter": [
            "lowercase"
          ]
        }
      }
    }
  },
  "mappings": {
    "doctype": {
      "properties": {
        "hashtags": {
          "type": "keyword",
          "normalizer": "lowercase_normalizer"
        }
      }
    },
    "queries": {
      "properties": {
        "query": {
          "type": "percolator"
        }
      }
    }
  }
}

[2] Add a percolator query

POST test/queries
{
  "query": {
    "match": {
      "hashtags": "#thisisthetesthashtag"
    }
  }
}

[3] Perform a search operation with highlighting

GET test/_search
{
  "highlight": {
    "fields": {
      "*": {
        "type": "unified"
      }
    },
    "post_tags": [
      "</highlight>"
    ],
    "pre_tags": [
      "<highlight>"
    ]
  },
  "query": {
    "percolate": {
      "field": "query",
      "document_type": "doctype",
      "document": {
        "hashtags": ["#ThisIsTheTestHashtag"]
      }
    }
  }
}

Result:

{
  "took": 3,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0.2876821,
    "hits": [
      {
        "_index": "test",
        "_type": "queries",
        "_id": "AVuM-0xo4UCyeiU_VRN4",
        "_score": 0.2876821,
        "_source": {
          "query": {
            "match": {
              "hashtags": "#thisisthetesthashtag"
            }
          }
        },
        "highlight": {
          "hashtags": [
            "#ThisIsTheTestHashtag"   <--- HIGHLIGHT WORK , WITHOUT post/pre tags
          ]
        }
      }
    ]
  }
}
@clintongormley clintongormley added the :Search/Highlighting How a query matched a document label Apr 25, 2017
@jimczi
Copy link
Contributor

jimczi commented Mar 14, 2018

This issue is fixed in 6.x, hence closing.

@jimczi jimczi closed this as completed Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Highlighting How a query matched a document
Projects
None yet
Development

No branches or pull requests

3 participants