Weighted order


(Lucas Rodriguez) #1

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.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #2