# Weighted order

**URL:** <https://discuss.elastic.co/t/weighted-order/13476>\
**Category:** Elasticsearch\
**Created:** [September 5, 2013, 1:48pm UTC](https://discuss.elastic.co/t/weighted-order/13476 "2013-09-05T13:48:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Rodriguez](https://avatars.discourse-cdn.com/v4/letter/l/d78d45/32.png) [@Lucas\_Rodriguez](https://discuss.elastic.co/u/Lucas_Rodriguez)\
**Post date:** [September 5, 2013, 1:48pm UTC](https://discuss.elastic.co/t/weighted-order/13476/1 "2013-09-05T13:48:20Z")

</div>

Hi! I'm trying to find an optimal solution to my search algorythm.  
I'm using something that seems like an weighted order, but i'm not sure  
this is optimal.

Our query looks like this:

{

"from": 0,

"size": 50,

"min\_score": 0.1,

"fields": [

```
"id",

"titulo"

```

],

"highlight": {

```
"fields": {

  "titulo": {

    

  }

},

"pre_tags": [

  ""

],

"post_tags": [

  ""

]

```

},

"query": {

```
"filtered": {

  "query": {

    "custom_filters_score": {

      "query": {

        "dis_max": {

          "queries": [

            {

              "query_string": {

                "default_field": "titulo",

                "query": "prueba",

                "default_operator": "AND"

              }

            },

            {

              "query_string": {

                "default_field": "titulo",

                "query": "prueba",

                "default_operator": "OR"

              }

            },

            {

              "fuzzy_like_this": {

                "fields": [

                  "titulo"

                ],

                "like_text": "prueba",

                "max_query_terms": 12

              }

            },

            {

              "query_string": {

                "default_field": "descripcion",

                "query": "prueba",

                "default_operator": "AND"

              }

            },

            {

              "query_string": {

                "default_field": "descripcion",

                "query": "prueba",

                "default_operator": "OR"

              }

            },

            {

              "fuzzy_like_this": {

                "fields": [

                  "descripcion"

                ],

                "like_text": "prueba",

                "max_query_terms": 12

              }

            }

          ]

        }

      },

      "filters": [

        {

          "filter": {

            "term": {

              "oferta": 1

            }

          },

          "boost": 8

        },

        {

          "filter": {

            "term": {

              "destacado": 1

            }

          },

          "boost": 6

        },

        {

          "filter": {

            "range": {

              "ratio": {

                "from": 0,

                "to": 1

              }

            }

          },

          "boost": 1

        },

        {

          "filter": {

            "range": {

              "ratio": {

                "from": 1,

                "to": 2

              }

            }

          },

          "boost": 2.5

        },

        {

          "filter": {

            "range": {

              "ratio": {

                "from": 2,

                "to": 100

              }

            }

          },

          "boost": 5

        },

        {

          "filter": {

            "range": {

              "calidad": {

                "from": 0,

                "to": 10

              }

            }

          },

          "boost": 0.3

        },

        {

          "filter": {

            "range": {

              "calidad": {

                "from": 11,

                "to": 20

              }

            }

          },

          "boost": 0.6

        },

        {

          "filter": {

            "range": {

              "calidad": {

                "from": 21,

                "to": 30

              }

            }

          },

          "boost": 0.9

        },

        {

          "filter": {

            "range": {

              "calidad": {

                "from": 31,

                "to": 40

              }

            }

          },

          "boost": 1.2

        },

        {

          "filter": {

            "range": {

              "calidad": {

                "from": 41,

                "to": 50

              }

            }

          },

          "boost": 1.5

        },

        {

          "filter": {

            "range": {

              "calidad": {

                "from": 51,

                "to": 60

              }

            }

          },

          "boost": 1.8

        },

        {

          "filter": {

            "range": {

              "calidad": {

                "from": 61,

                "to": 70

              }

            }

          },

          "boost": 2.1

        },

        {

          "filter": {

            "range": {

              "calidad": {

                "from": 71,

                "to": 80

              }

            }

          },

          "boost": 2.4

        },

        {

          "filter": {

            "range": {

              "calidad": {

                "from": 81,

                "to": 90

              }

            }

          },

          "boost": 2.7

        },

        {

          "filter": {

            "range": {

              "calidad": {

                "from": 91,

                "to": 100

              }

            }

          },

          "boost": 3

       },

        {

          "filter": {

            "range": {

              "miembro_valoracion": {

                "from": 0,

                "to": 10

              }

            }

          },

          "boost": 0.3

        },

        {

          "filter": {

            "range": {

              "miembro_valoracion": {

                "from": 11,

                "to": 20

              }

            }

          },

          "boost": 0.6

        },

        {

          "filter": {

            "range": {

              "miembro_valoracion": {

                "from": 21,

                "to": 30

              }

            }

          },

          "boost": 0.9

        },

        {

          "filter": {

            "range": {

              "miembro_valoracion": {

                "from": 31,

                "to": 40

              }

            }

          },

          "boost": 1.2

        },

        {

          "filter": {

            "range": {

              "miembro_valoracion": {

                "from": 41,

                "to": 50

              }

            }

          },

          "boost": 1.5

        },

        {

          "filter": {

            "range": {

              "miembro_valoracion": {

                "from": 51,

                "to": 60

              }

            }

          },

          "boost": 1.8

        },

        {

          "filter": {

            "range": {

              "miembro_valoracion": {

                "from": 61,

                "to": 70

              }

            }

          },

          "boost": 2.1

        },

        {

          "filter": {

            "range": {

              "miembro_valoracion": {

                "from": 71,

                "to": 80

              }

            }

          },

          "boost": 2.4

        },

        {

          "filter": {

            "range": {

              "miembro_valoracion": {

                "from": 81,

                "to": 90

              }

            }

          },

          "boost": 2.7

        },

        {

          "filter": {

            "range": {

              "miembro_valoracion": {

                "from": 91,

                "to": 100

              }

            }

          },

          "boost": 3

        }

      ],

      "score_mode": "total"

    }

  },

  "filter": {

    "bool": {

      "must": {

        "and": [

          {

            "term": {

              "vencido": 0

            }

          },

          {

            "term": {

              "eliminado": 0

            }

          },

          {

            "term": {

              "miembro.estado": 0

            }

          }

        ]

      }

    }

  }

}

```

}

}

Basically we list all the things that matter to the query, and we associate  
a boost to them. Is it correct? Is there an better solution? Because the  
query seems too long and complicated...

Thank you!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:18am UTC](https://discuss.elastic.co/t/weighted-order/13476/2 "2017-07-06T02:18:00Z")

</div>

Closed on July 6, 2017, 2:18am UTC


