# Searching by Ranked information

**URL:** <https://discuss.elastic.co/t/searching-by-ranked-information/201422>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [September 27, 2019, 3:05pm UTC](https://discuss.elastic.co/t/searching-by-ranked-information/201422 "2019-09-27T15:05:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Williams1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_williams1/32/42126_2.png) [@David\_Williams1](https://discuss.elastic.co/u/David_Williams1)\
**Post date:** [September 27, 2019, 3:05pm UTC](https://discuss.elastic.co/t/searching-by-ranked-information/201422/1 "2019-09-27T15:05:13Z")

</div>

Elastic has the ability to do a ranked search but I cannot see that I can store the information in the document and then return the documents based on the rank.

This an example of how I would store the information in a field (but I am open to anything) but I'm not sure if/how to query the engine to sort based on Topic A's rank.

[{"Topic A":.5}, ("Topic B":.855}, {"Topic C":.255}, {"Topic D":.641}, {"Topic E":.500}, {"Topic F":.541}, {"Topic G":.523}]

Has anyone done this or something similar?

[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-rank-feature-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-rank-feature-query.html)

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [October 2, 2019, 4:28pm UTC](https://discuss.elastic.co/t/searching-by-ranked-information/201422/2 "2019-10-02T16:28:09Z")

</div>

@David\_Williams1To be honest, I'm not actually sure what you're asking.

I think there are a couple of options for boosting scores based on field values. Since you have numeric values, perhaps a "functional boost" is what you're looking for? [https://swiftype.com/documentation/app-search/guides/relevance-tuning#boosts](https://swiftype.com/documentation/app-search/guides/relevance-tuning#boosts)

I think you'll need to make "topic\_a", "topic\_b", etc. discrete document fields though.

Take a look at the doc I linked and let me us know if that helps.

---

<div class="post-metadata">

**Author:** ![David\_Williams1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_williams1/32/42126_2.png) [@David\_Williams1](https://discuss.elastic.co/u/David_Williams1)\
**Post date:** [October 2, 2019, 6:50pm UTC](https://discuss.elastic.co/t/searching-by-ranked-information/201422/3 "2019-10-02T18:50:24Z")

</div>

Thank you for your reply.

The relevance tuning won't work since I can't make each topic a discrete field as there are 100,000's of entries.

Another way to look at what I want to do is say if I have 4 documents that discuss water quality in Lake Ontario and each of them has 'water quality' as a topic but each has a different weighted value. I want to return those documents in order of the weighted value.

I would also want to return only the documents where the weighted value is over a certain value.

In any relational DB I could do this easily so I'm thinking there has got to be a way in Elastic.

David

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [October 4, 2019, 11:45am UTC](https://discuss.elastic.co/t/searching-by-ranked-information/201422/4 "2019-10-04T11:45:30Z")

</div>

@David_Williams1 Yeah, unfortunately we don't have a great solution for nested fields like this right now.

The only way I think you'll get this working is with duplicate documents. Probably some setup where you have the same document duplicated with the various topic values.

That would let you filter by "topic" and sort by "topic\_value".

You could also leverage the [grouping](https://swiftype.com/documentation/app-search/api/search/grouping) feature when necessary to avoid duplication in results.

There's a number of drawbacks with this approach. For instance, I don't think curations will work with grouping, and the counts provided in facets when using grouping are not always what you would expect.

There's also a maintenance burden associated with this, trying to maintain multiple variations of a single document.

```auto
[{
  name: "Yellowstone park",
  topic: "Topic A",
  topic_value: "1.5"
}, {
  name: "Yellowstone park",
  topic: "Topic B",
  topic_value: "2.0"
}]

```

Probably not the answer you were hoping for, hopefully this helps though.

---

<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:** [November 1, 2019, 11:45am UTC](https://discuss.elastic.co/t/searching-by-ranked-information/201422/5 "2019-11-01T11:45:31Z")

</div>

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