Document looks like this,

{
    "_index": "mdb-pod1-1",
    "_type": "file",
    "_id": "81f87ac0-8362-43f0-bdf2-485d109bed18",
    "_score": 1,
    "_source": {
        "fileName": "documents.txt",
        "fileExtension": "txt",
        "pid": 1,
        "folderName": "Documents",
        "trash": false,
        "content": "This is fine and documents are working fine.\n\n"
    }
}


Mapping looks like this,

  "fileName": {
          "type": "multi_field",
          "fields": {
            "fileName": {
              "type": "string",
              "analyzer": "generic_name_analyzer"
            },
            "trigram": {
              "type": "string",
              "analyzer": "trigram_name_analyzer"
            }
          }
        },
 "folderName": {
          "type": "multi_field",
          "fields": {
            "folderName": {
              "type": "string",
              "analyzer": "generic_name_analyzer"
            },
            "trigram": {
              "type": "string",
              "analyzer": "trigram_name_analyzer"
            }
          }
        },
  "content": {
          "type": "string",
          "analyzer": "generic_text_analyzer"
        },

 "analyzer": {
         "generic_name_analyzer": {
          "filter": [
            "subword_split",
              "extension_split",
            "icu_folding",
            "english_stop"
          ],
          "type": "custom",
          "tokenizer": "icu_tokenizer"
        },
        "generic_text_analyzer": {
          "filter": [
            "subword_split",
            "icu_folding",
            "english_stop",
            "max_token_limit"
          ],
          "type": "custom",
          "tokenizer": "icu_tokenizer"
        },
        "trigram_name_analyzer": {
          "filter": [
            "icu_folding",
            "trigram_filter"
          ],
          "type": "custom",
          "tokenizer": "icu_tokenizer"
        }
      }


On Wednesday, November 26, 2014 9:59:55 PM UTC+5:30, Nikolas Everett wrote:
>
> Can you post an example document?  Can you post your mapping?  Mapping is 
> important because depending on how your mapping is set up you'll get a 
> totally different highlighter implementation.
>
> Nik
>
> On Wed, Nov 26, 2014 at 11:26 AM, Deepak Mehta <[email protected] 
> <javascript:>> wrote:
>
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/elasticsearch/5fffefc1-c2f3-4b2d-aa64-b804da6dc3ff%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/elasticsearch/5fffefc1-c2f3-4b2d-aa64-b804da6dc3ff%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/ae0cc53f-ab26-47d6-a4bb-4b2b3e59292d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to