# How to design schema for boosting/ranking logic?

**URL:** <https://discuss.elastic.co/t/how-to-design-schema-for-boosting-ranking-logic/284149>\
**Category:** Elasticsearch\
**Created:** [September 14, 2021, 6:38am UTC](https://discuss.elastic.co/t/how-to-design-schema-for-boosting-ranking-logic/284149 "2021-09-14T06:38:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhinavkulkarni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhinavkulkarni/32/91428_2.png) [@abhinavkulkarni](https://discuss.elastic.co/u/abhinavkulkarni)\
**Post date:** [September 14, 2021, 6:38am UTC](https://discuss.elastic.co/t/how-to-design-schema-for-boosting-ranking-logic/284149/1 "2021-09-14T06:38:34Z")

</div>

Hi,

Let us say, I am indexing a bunch of podcasts in my Elasticsearch cluster:

```auto
    Podcast:
      - _id (keyword)
      - email (keyword)
      - webLink (keyword)
      - rssLink (keyword)
      - shortDescription (text)
      - longDescription (text)
      - artistIds (array of integers)
      - imageLink (keyword)
      - numEpisodes (integer)

```

I want to submit queries to select podcasts for a text query and optionally boost score based on presence of certain fields. For e.g., I'd like to boost scores if a podcast has a link, short Description or image.

For a faster execution, should I have `hasWebLink`, `hasShortDescription` and `hasImageLink` fields or `exists` clause for these fields.

I am wondering if having separate fields and setting `index=True` for those would result in faster execution.

Thanks

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 14, 2021, 7:59am UTC](https://discuss.elastic.co/t/how-to-design-schema-for-boosting-ranking-logic/284149/2 "2021-09-14T07:59:07Z")

</div>

`exists` clause in the `should` part of a boolean query sounds like a good way to do this. No need for further tuning.

---

<div class="post-metadata">

**Author:** ![abhinavkulkarni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhinavkulkarni/32/91428_2.png) [@abhinavkulkarni](https://discuss.elastic.co/u/abhinavkulkarni)\
**Post date:** [September 14, 2021, 8:37am UTC](https://discuss.elastic.co/t/how-to-design-schema-for-boosting-ranking-logic/284149/3 "2021-09-14T08:37:57Z")

</div>

Thanks @spinscale for the reply.

As you mentioned, I am currently including the `exists` conditions with score boosting in a `should` clause.

According to the documentation [here](https://www.elastic.co/guide/en/elasticsearch/guide/current/filter-caching.html), a filter bitset is cached for potential reuse. If I do not explicitly define `hasXYZ` fields and an index on them, do my queries benefit from such filter bitset caching?

Thanks!

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 14, 2021, 9:39am UTC](https://discuss.elastic.co/t/how-to-design-schema-for-boosting-ranking-logic/284149/4 "2021-09-14T09:39:51Z")

</div>

Those bitsets are only used for a filter context, however in your case the exists query is part of the scoring.

---

<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:** [October 12, 2021, 9:40am UTC](https://discuss.elastic.co/t/how-to-design-schema-for-boosting-ranking-logic/284149/5 "2021-10-12T09:40:15Z")

</div>

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