ES returns query match but won't highlight


(Shaybix) #1

I have indexed Arabic books and when I query the content I get match, but no highlighting.

This is the query I ran (I modified the documentation example):

{
    "query" : {
        "match": {
           "page_body": "الله"
        }
    },
    "highlight" : {
        "fields" : {
            "_all" : { "pre_tags" : ["<em>"], "post_tags" : ["</em>"] }
        }
    }
}

Am I doing something wrong?


(昕玫) #2

Is it a problem about Arabic language compatible? Can you give more imformation like your indexed doc and the return of this query.


(Shaybix) #3

I managed to resolve the issue. I didn't know in my mappings I had to set the field I wanted to later on get highlights, the store as true.

"mappings" : {
    "pages" : {
        "_source" : { "enabled" : true },
        "properties" : {
            "page_body": {
                "type": "string",
                "index": "analyzed",
                "store": true
            },
            "book": {
                "properties": {
                    "category" : { "type" : "string", "index" : "not_analyzed" }
                    }
                }
            }
        }
    }
}

and then the query like this:

{
    "query" : {
        "match": {
           "page_body": "الله"
        }
    },
    "highlight" : {
        "fields" : {
            "page_body" : {
                "pre_tags" : ["</em>"],
                "post_tags": ["<em>"]
            }
        }
    }
}

Thanks for the quick reply.


(system) #4