1

I am working on a project that involves Elasticsearch. So far I can get most function to work except highlight. I am using Laravel + Elasticsearch official PHP client.

Previously I thought it was a problem of my PHP code, and asked a question here: highlight field missing from Elasticsearch results, PHP

Later when I tried with elasticsearch-head in browser, I still cannot see highlight field in results, so I guess there must be something wrong with either my settings of elasticsearch or the way I indexed the documents.

Here is the query I entered into elasticsearch-head:

{
"query" : {
    "match" : {
        "combined" : "DNA"
    }
},
"highlight": {
    "fields" : {
        "combined" : {}
    }
}
}

And I don't see "highlight" after "_source" in hits returned by elasticsearch.

What might I did wrong here?

Please advise,

Thanks.

Update: I'm running Elasticsearch 2.3.3, on Ubuntu 16.04 LTS desktop, JDK 1.8.

Documentation says "store" in mapping needs to be set true. I did so, and re-indexed a bunch of documents. This didn't fix the problem.

2
  • What is your mapping? And please give a one document example... Commented Jul 17, 2016 at 19:38
  • I followed the example here: elastic.co/guide/en/elasticsearch/client/php-api/current/… The advanced example with slight customization. Later on as I stated in answer, the problem is really "store" needs to be set true. Something I overlooked at the beginning. Commented Jul 18, 2016 at 3:10

1 Answer 1

-1

OK, after stopping and restarting elasticsearch service, my code started to work as intended. I got "highlight" field in results.

The issue is that I need to set "store" to true. Everything else being equal, including the following line

"store"   =>   true

in mapping ensured "highlight" appear in the results I have. Vice versa.

Not sure why doing this earlier didn't solve my problem.

Sign up to request clarification or add additional context in comments.

1 Comment

Where do you add "store" => true ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.