Apoorv Saxena
Apoorv Saxena

Reputation: 4236

Searching and sorting on dynamic fields in ElasticSearch

Have created an object of colors, which contains the hex code of colors along with it's percentage,

/colors/mapping returns

{   
  "colors": {
    "mappings": {
      "colors_array": {
        "dynamic": "strict",
        "properties": {
          "colors": {
            "dynamic": "true",
            "properties": {
              "#2f4f4f": {
                "type": "long"
              },
              "#808080": {
                "type": "long"
              },
              "#bc8f8f": {
                "type": "long"
              },
              "#dc143c": {
                "type": "long"
              },
              "#e6e6fa": {
                "type": "long"
              }
            }
          }
        }
      }
    }
  }
}

Note: Color hex codes are created as dynamic mapping objects

How exactly should I formulate the query such that I pass specific colors and the results are sorted on the basis of aggregated matching percentage i.e. sum the percentage of the colors that match and sort the results on the basis of this figure?

Upvotes: 0

Views: 522

Answers (0)

Related Questions