Multi match with different slops and with multi filters search use case

Hi All,

I have a use case where i need to search for a phrase(with different slops) either in title or content(body) of the document and also add filters for the above search case. With the below query, I get documents even with score 0( non matching documents). Can you please help me where am I going wrong

Query:

> {
>    "size":5,
>    "fields":[
>       "title",
>       "product",
>       "url",
>       "subject"
>    ],
>    "query":{
>       "bool":{
>          "filter":[
>             {
>                "terms":{
>                   "product":[
>                      "Books"
>                   ]
>                }
>             },
>             {
>                "terms":{
>                   "subject":[
>                      "About This Help"
>                   ]
>                }
>             }
>          ],
>          "should":[
>             {
>                "match_phrase_prefix":{
>                   "title.autocomp":{
>                      "query":"cro",
>                      "boost":5,
>                      "slop":3
>                   }
>                }
>             },
>             {
>                "match_phrase_prefix":{
>                   "content.autocomp":{
>                      "query":"cro",
>                      "boost":2,
>                      "slop":10
>                   }
>                }
>             }
>          ]
>       }
>    },
>    "highlight":{
>       "pre_tags":[
>          "<b>"
>       ],
>       "post_tags":[
>          "</b>"
>       ],
>       "fields":{
>          "content.autocomp":{

>          },
>          "title.autocomp":{

>          }
>       }
>    }
> }

Results:

> {
>   "took": 12,
>   "timed_out": false,
>   "_shards": {
>     "total": 5,
>     "successful": 5,
>     "failed": 0
>   },
>   "hits": {
>     "total": 15,
>     "max_score": 0.062365085,
>     "hits": [
>       {
>         "_index": "psbooks",
>         "_type": "topic",
>         "_id": "aHR0cDovL3NsYzA2d2xpLnVzLm9yYWNsZS5jb20vd2VidGVzdC9vdXQ4NTUvY3NfMTE3MDc2MTE0NGgyL3dlYi9oZWxwLVBCL2VuZy9jcy9hdHBiL3Rhc2tfRGlzYWJsaW5nRGVsaXZlcmVkUHJvZHVjdHNPclN1YmplY3RzLmh0bWw=",
>         "_score": 0.062365085,
>         "fields": {
>           "product": [
>             "Books"
>           ],
>           "title": [
>             "Disabling Delivered Products or Subjects"
>           ],
>           "url": [
>             "http://internal.com/webtest/out855/cs_1170761144h2/web/help-PB/eng/cs/atpb/task_DisablingDeliveredProductsOrSubjects.html"
>           ],
>           "subject": [
>             "About This Help"
>           ]
>         },
>         "highlight": {
>           "content.autocomp": [
>             " remove destinations for the tupa subject folder. The removed destinations have been <b>crossed</b> out to show"
>           ]
>         }
>       },
>       {
>         "_index": "psbooks",
>         "_type": "topic",
>         "_id": "aHR0cDovL3NsYzA2d2xpLnVzLm9yYWNsZS5jb20vd2VidGVzdC9vdXQ4NTUvY3NfMTE3MDc2MTE0NGgyL3dlYi9oZWxwLVBCL2VuZy9jcy9hdHBiL3Rhc2tfU2VhcmNoaW5nQUxvY2FsbHlJbnN0YWxsZWRQZW9wbGVTb2Z0T25saW5lSGVscFdlYnNpdGUuaHRtbA==",
>         "_score": 0,
>         "fields": {
>           "product": [
>             "Books"
>           ],
>           "title": [
>             "Searching a Locally Installed PeopleSoft Online Help Website"
>           ],
>           "url": [
>             "http://internal.com/webtest/out855/cs_1170761144h2/web/help-PB/eng/cs/atpb/task_SearchingALocallyInstalledPeopleSoftOnlineHelpWebsite.html"
>           ],
>           "subject": [
>             "About This Help"
>           ]
>         }
>       },
>       {
>         "_index": "psbooks",
>         "_type": "topic",
>         "_id": "aHR0cDovL3NsYzA2d2xpLnVzLm9yYWNsZS5jb20vd2VidGVzdC9vdXQ4NTUvY3NfMTE3MDc2MTE0NGgyL3dlYi9oZWxwLVBCL2VuZy9jcy9hdHBiL3Rhc2tfQWRkaW5nQXR0cmlidXRlRmlsdGVyc0ZvclNlYXJjaFJlc3VsdHMuaHRtbA==",
>         "_score": 0,
>         "fields": {
>           "product": [
>             "Books"
>           ],
>           "title": [
>             "Adding Attribute Filters for Search Results"
>           ],
>           "url": [
>             "http://internal.com/webtest/out855/cs_1170761144h2/web/help-PB/eng/cs/atpb/task_AddingAttributeFiltersForSearchResults.html"
>           ],
>           "subject": [
>             "About This Help"
>           ]
>         }
>       },
>       {
>         "_index": "psbooks",
>         "_type": "topic",
>         "_id": "aHR0cDovL3NsYzA2d2xpLnVzLm9yYWNsZS5jb20vd2VidGVzdC9vdXQ4NTUvY3NfMTE3MDc2MTE0NGgyL3dlYi9oZWxwLVBCL2VuZy9jcy9hdHBiL3Rhc2tfQWNjZXNzaW5nVGhlUGVvcGxlU29mdE9ubGluZUhlbHBBbmRQZW9wbGVCb29rcy5odG1s",
>         "_score": 0,
>         "fields": {
>           "product": [
>             "Books"
>           ],
>           "title": [
>             "Accessing the PeopleSoft Online Help and PeopleBooks"
>           ],
>           "url": [
>             "http://internal.com/webtest/out855/cs_1170761144h2/web/help-PB/eng/cs/atpb/task_AccessingThePeopleSoftOnlineHelpAndPeopleBooks.html"
>           ],
>           "subject": [
>             "About This Help"
>           ]
>         }
>       },
>       {
>         "_index": "psbooks",
>         "_type": "topic",
>         "_id": "aHR0cDovL3NsYzA2d2xpLnVzLm9yYWNsZS5jb20vd2VidGVzdC9vdXQ4NTUvY3NfMTE3MDc2MTE0NGgyL3dlYi9oZWxwLVBCL2VuZy9jcy9hdHBiL2NvbmNlcHRfVW5kZXJzdGFuZGluZ0hlbHBDb250ZW50TWFuYWdlbWVudC5odG1s",
>         "_score": 0,
>         "fields": {
>           "product": [
>             "Books"
>           ],
>           "title": [
>             "Understanding Help Content Management"
>           ],
>           "url": [
>             "http://internal.com/webtest/out855/cs_1170761144h2/web/help-PB/eng/cs/atpb/concept_UnderstandingHelpContentManagement.html"
>           ],
>           "subject": [
>             "About This Help"
>           ]
>         }
>       }
>     ]
>   }
> }

Can anyone please advice/guide

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.