# Query hints - make some records more important than others

**URL:** <https://discuss.elastic.co/t/query-hints-make-some-records-more-important-than-others/278869>\
**Category:** Logstash\
**Created:** [July 16, 2021, 8:31am UTC](https://discuss.elastic.co/t/query-hints-make-some-records-more-important-than-others/278869 "2021-07-16T08:31:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prze\_gee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prze_gee/32/83206_2.png) [@prze\_gee](https://discuss.elastic.co/u/prze_gee)\
**Post date:** [July 16, 2021, 8:31am UTC](https://discuss.elastic.co/t/query-hints-make-some-records-more-important-than-others/278869/1 "2021-07-16T08:31:39Z")

</div>

Let say I have an index of cities: cities\_ind. I'm querying this data with search\_at\_you\_type to get the best recommendation while typing. Then, I want to make a few of them more important than others. The biggest cities, like Cracow, Warsaw, Gdansk are to be preferable over other cities with the same starting letters.

My mapping is:

```auto
{
   "mappings":{
      "properties":{
         "city_name":{
            "type":"search_as_you_type"
         },
         "city_name_txt":{
            "type":"keyword",
            "fields":{
               "keyword":{
                  "type":"keyword",
                  "ignore_above":256
               }
            }
         }
      }
   }
}

```

(cities\_ind\_txt is for collapse used in query)

And my query is:

```auto
{
   "size":10,
   "sort":[
      {
         "_score":"desc"
      }
   ],
   "query":{
      "multi_match":{
         "query": f'{key}',
         "fuzziness":2,
         "type":"best_fields",
         "fields":[
            "city_name",
            "city_name._indiex_prefix",
            "city_name._2gram",
            "city_name._3gram"
         ]
      }
   },
   "collapse":{
      "field":"city_name_txt.keyword"
   }
}

```

One idea is to add a special field with weights, but it would implicate database structure changing. Any other options? Like array of important keywords? Or may be it is possible to add weights while indexing (loading data from db)?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 13, 2021, 8:32am UTC](https://discuss.elastic.co/t/query-hints-make-some-records-more-important-than-others/278869/2 "2021-08-13T08:32:31Z")

</div>

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