Is there a way to ask for the number of occurrences of a given phrase 
within a single field?  The phrase can contain spaces.

I have been able to count instances of a single word using the terms 
aggregation, but that doesn't seem to work for phrases.  I tried including 
double quotes around the phrase inside the "include" field of the terms 
aggregation, but that didn't seem to help.

For example, this will count occurrences of the word "language".

{
  "query": {
    "query_string": {
      "query": "DocumentText:(\"language skills\")"
    }
  },
  "aggs" : {
    "count_terms": {
      "terms" : {
        "field" : "DocumentText", "include":"language"
      }
    }
  }
}

But what I really need is to count of the occurrences of the full phrase 
"language skills" since "language" can occur without being followed by 
"skills", but the below doesn't work.

{
  "query": {
    "query_string": {
      "query": "DocumentText:(\"language skills\")"
    }
  },
  "aggs" : {
    "count_terms": {
      "terms" : {
        "field" : "DocumentText", "include":"\"language skills\""
      }
    }
  }
}

Thanks... 

-- 
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 elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/f0640b7f-1265-411f-884b-40c2bb0f55bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to