I am using Elastic Search 1.3.5. 
I have fields like filename, foldername and content. In query I am trying 
to highlight matched content.

In Query if keyword only matches in content then keyword is highlighted and 
its becoming bold. However if keyword matches in (filename or foldername) 
and content then content is not highlighted.
What I am missing here?

Query sample, 

{
    "query": {
        "filtered": {
            "query": {
                "bool": {
                    "should": [
                        {
                            "match": {
                                "fileName": {
                                    "query": "document",
                                    "boost": 4
                                }
                            }
                        },
                        {
                            "match": {
                                "folderName": {
                                    "query": "document",
                                    "boost": 3
                                }
                            }
                        },
                        {
                            "match": {
                                "fileName.trigram": {
                                    "query": "document",
                                    "boost": 2,
                                    "minimum_should_match": "50%"
                                }
                            }
                        },
                        {
                            "match": {
                                "content": {
                                    "query": "document",
                                    "boost": 5
                                }
                            }
                        },
                        {
                            "match": {
                                "folderName.trigram": {
                                    "query": "document",
                                    "boost": 1,
                                    "minimum_should_match": "50%"
                                }
                            }
                        }
                    ]
                }
            },
            "filter": {
                "and": [
                    {
                        "term": {
                            "businessId": 1
                        }
                    },
                    {
                        "term": {
                            "deleted": false
                        }
                    },
                    {
                        "bool": {
                            "should": [
                                {
                                    "term": {
                                        "folderPath": "/shared/documents"
                                    }
                                },
                                {
                                    "prefix": {
                                        "folderPath": "/shared/documents/"
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        }
    },
    "highlight": {
        "fields": {
            "content": {
                "fragment_size": 150,
                "number_of_fragments": 0,
                "no_match_size": 150
            }
        },
        "pre_tags": [
            "<Bold>"
        ],
        "post_tags": [
            "</Bold>"
        ]
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/5fffefc1-c2f3-4b2d-aa64-b804da6dc3ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to