I have created index for documents by setting the "snowball" analyzer for "content" filed in mapping.
Please check the following mapping for "content" filed of document.
"content": {
"type": "attachment",
"path": "full",
"fields": {
"content": {
"type": "string",
"store": true,
"term_vector": "with_positions_offsets",
"analyzer": "snowball"
},
"author": {
"type": "string"
},
"title": {
"type": "string",
"store": true
},
"name": {
"type": "string"
},
"date": {
"type": "date",
"format": "dateOptionalTime"
},
"keywords": {
"type": "string"
},
"content_type": {
"type": "string"
},
"content_length": {
"type": "integer"
},
"language": {
"type": "string"
}
}
}
While searching for document, we are also fetching the matching snippets using the following search query.
GET _search
{
"query" : {
"bool" : {
"must" : {
"bool" : {
"should" : [ {
"match" : {
"content" : {
"query" : "\"book to bill ratio\"",
"type" : "phrase"
}
}
} ],
"minimum_should_match" : "1"
}
}
}
},
"highlight" : {
"fields" : {
"content" : { }
}
}
}
We have noticed an issue in searching for phrases, whenever stop words (such as "to", "and", "is" etc) present in search phrase, above query is able to find the matching document. But, it failed to find the matching snippets inside the document.
We are using the Elastic search version: 1.7.3
Appreciate your help.