elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
1.09k stars 24.83k forks source link

Add cosineSimilarity and dotProduct function to rank_feature query #64436

Open mayya-sharipova opened 4 years ago

mayya-sharipova commented 4 years ago

Currently rank_feature query on rank_features field type supports only 3 functions: log, sigmoid and saturation.

Consider adding additional functions of cosineSimilarity and dotProduct only for rank_features field. The API could like this:

"rank_feature": {
    "field": "topics",
    "cosine_similarity": {
      "sports": 20,
      "brazil": 10
    }
  }

For the internal implementation we may rewrite it to a bool query, so the number of sparse fields on which to compute a function should be low (< 1024).

elasticmachine commented 4 years ago

Pinging @elastic/es-search (:Search/Ranking)

jtibshirani commented 4 years ago

Clarifying one point: I think all the values in the query need to be strictly positive (which matches what rank_features accepts).

elasticsearchmachine commented 4 months ago

Pinging @elastic/es-search-relevance (Team:Search Relevance)