Is there a way to pull up only the top 2 results based on _score for docs 
with the same value in a certain field?

the hits before this filter would be like:

{ 
   "_index":"myindex",
   "_score":100,
   "_source": {
      "myfield1": "i have a twin",
      "name":"fred"
    }
},

{ 
   "_index":"myindex",
   "_score":50,
   "_source": {
      "myfield1": "i have a twin",
      "name":"george"
    }
},

{ 
   "_index":"myindex",
   "_score":10,
   "_source": {
      "myfield1": "i have a twin",
      "name":"tom"
    }
},

{ 
   "_index":"myindex",
   "_score":10,
   "_source": {
      "myfield1": "i DONT have a twin",
      "name":"doug"
    }
}

Then after this filter I want this ... tom removed because he has same 
value for myfield1, but the lowest score. Doug stays because he has a 
different value for myfield1.

{ 
   "_index":"myindex",
   "_score":100,
   "_source": {
      "myfield1": "i have a twin",
      "name":"fred"
    }
},

{ 
   "_index":"myindex",
   "_score":50,
   "_source": {
      "myfield1": "i have a twin",
      "name":"george"
    }
},

{ 
   "_index":"myindex",
   "_score":10,
   "_source": {
      "myfield1": "i DONT have a twin",
      "name":"doug"
    }
}

I would like to incorporate this (filter?) in my query here...
{
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "should": [
            {
              "match_phrase_prefix": {
                "myfield": {
                  "query": "i have",
                  "fuzziness": 1,
                  "slop":2,
                  "max_expansions": 10,
                  "prefix_length": 1
                }
              }
            }
          ]
        }
      },
      "boost_mode": "replace",
      "functions": [
        {
          "script_score": {
            "script": "_score * ..."
          }
        }
      ]
    }
  }
}


-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/69c0419c-5a2f-4f3a-9a33-2c75353e81f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to