0

I'm using ReactiveSearch to support queries on a shopping website. However if I search "tops", then the query matches descriptions containining words like "topshop", and those results are ranked more highly than descriptions with just "tops". How can I disable all prefix matching?

I'm using the ReactiveSearch library with the following configuration:

const DataSearchProps = {
    componentId: 'q',
    dataField: ['title', 'filter_color', 'category', 'brand', 'description', 'size_type'],
    fieldWeights: [1000, 500, 100, 50, 5, 5, 1, 10],
    placeholder: 'Search 1M+ Clothes...',
    iconPosition: 'right',
    queryFormat: 'and',
    fuzziness: 'AUTO',
    autosuggest: false,
    autoFocus: true,
    URLParams: true,
    className: 'searchbox',
    name: 'q',
}

This is an example query

{
   "query":{
      "bool":{
         "must":[
            {
               "bool":{
                  "must":[
                     {
                        "bool":{
                           "should":[
                              {
                                 "multi_match":{
                                    "query":"tops",
                                    "fields":[
                                       "allparel_tags^1000",
                                       "title^500",
                                       "brand^5",
                                       "raw_category^5",
                                       "description^1",
                                       "size_type^50"
                                    ],
                                    "type":"cross_fields",
                                    "operator":"and"
                                 }
                              },
                              {
                                 "multi_match":{
                                    "query":"tops",
                                    "fields":[
                                       "allparel_tags^1000",
                                       "title^500",
                                       "brand^5",
                                       "raw_category^5",
                                       "description^1",
                                       "size_type^50"
                                    ],
                                    "type":"phrase_prefix",
                                    "operator":"and"
                                 }
                              }
                           ],
                           "minimum_should_match":"1"
                        }
                     },
                     {
                        "exists":{
                           "field":"raw_category.keyword"
                        }
                     },
                     {
                        "terms":{
                           "condition.keyword":[
                              "new"
                           ]
                        }
                     }
                  ]
               }
            }
         ]
      }
   },
   "size":20,
   "aggs":{
      "condition.keyword":{
         "terms":{
            "field":"condition.keyword",
            "size":100,
            "order":{
               "_count":"desc"
            }
         }
      }
   },
   "_source":{
      "includes":[
         "*"
      ],
      "excludes":[

      ]
   },
   "from":0,
   "sort":[
      {
         "_score":{
            "order":"desc"
         }
      }
   ]
}

Since it seems like ElasticSearch doesn't do prefix matching by default, I'm confused as to why prefix matching is happening. Any help is appreciated!

Amit
  • 30,756
  • 6
  • 57
  • 88
swooders
  • 141
  • 1
  • 8

0 Answers0