Change the scoring function for array using best score for elements


(Jack Tan) #1

Consider I have a text field called 'question' with element
['one','one shift','one apple'].
Now say the query is 'one' with the following search query:

query": {
    "match": {
        "question": {
            "query": 'one',
        }
    }
}

I want the scoring function to use the best score among the three matches 'one', 'one shift', 'one apple' for the text field. How should I modify that? I am aware there is a function score query, but I am not sure how to achieve that.


(Jaspreet Singh) #2

I'm not sure I understand the question.
For the given query, the document with the given question field would be returned as search result. The overall relevancy score for this document would depend on the tf, idf algorithm. There is no other competing field in query so you will get the best score for the document.
Are you seeing something else?


(Jack Tan) #3

Hi Jaspreet, I want the tf-idf to look at each element in the array (although all of them belong to a field), and return the max value.


(Jaspreet Singh) #4

I my opinion, I do not think there is any difference in the indexing (and subsequent matching) between a regular text datatype or array datatype.
For example ...

GET myindex/_analyze
{
  "field":"title",
  "text" : "Cognitive Computing"
}

GET myindex/_analyze
{
  "field":"title",
  "text" : ["Cognitive", "Computing"]
}

... yields exactly the same tokens. The specifics are then down to tf idf etc that in turn, as i said do not vary as the basic datatype of both fields is same - string/text.

Are you seeing any difference/unexpected outcome in behaviour?


(system) #5

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