I can search in documents for a term and get the count of that term in the 
document with

{
  "query": {
    "query_string": {
      "query": "myterm"
    }
  },
  "script_fields": {
    "term_count": {
      "script": "_index['text']['myterm'].tf()"
    }
  }
}

Now suppose that the query is something like "term1 term2"~4 (term1 and 
term2 with no more than 4 words between them), is that a way to obtain the 
number of match of this combination inside the documents? I can count 
occurrence of both terms with

{
  "query": {
    "query_string": {
      "query": "\"term1 term2\"~1"
    }
  },
  "script_fields": {
    "term1_count": {
      "script": "_index['text']['term1'].tf()"
    },
"term2_count": {
      "script": "_index['text']['term2"].tf()"
    }
  }
}

But this does not tells me if they are one near the other. I though of 
asking for highlight and count number of higlights but I think this is not 
so correct.

Any clue?

Thanks in advance for any help.

-- 
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/48f5dc53-17bb-483e-b4d7-2e0613729fe8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to