Querying indexed data


(ali ilyas) #1

Hi,
I have indexed data on elastic search node. The structure of document is it
has two fields namely , name and message. In message it contains text. Now
I want to count the occurance of some particular phrase that occurs in
messages.
Like http://localhost:9200/big/data/INDEXES OF DOCUMENTS
The structure of document is
{
"name":"xyz",
"message":"i like to eat king's burger. I go there quite often"
}
Now I have like 40thousand records. I want to calculate how many times
king's burger have been mentioned in the messages of all documents.
I am not able to make query for this, I now its trivial stuff but I am
quite new in elastic search. Your help is highly appreciated.

--


(Sushant Shankar) #2

Hi Ali,

If your index name is bigData, and the structure of the document is as you
described, the count query would look something like this:

curl -XGET 'http://localhost:9200/bigData/_search?' -d '
{
"query": {
"query_string": {
"fields": ["message"],
"query": ""king's burger""
}
}
}'

You should see the count of this under response's hits then total

For reference, check
out http://www.elasticsearch.org/guide/reference/api/search/request-body.html

Try the Count
API: http://www.elasticsearch.org/guide/reference/api/count.html

On Thursday, September 20, 2012 12:29:25 PM UTC-7, ali ilyas wrote:

Hi,
I have indexed data on elastic search node. The structure of document is
it has two fields namely , name and message. In message it contains text.
Now I want to count the occurance of some particular phrase that occurs in
messages.
Like http://localhost:9200/big/data/INDEXES OF DOCUMENTS
The structure of document is
{
"name":"xyz",
"message":"i like to eat king's burger. I go there quite often"
}
Now I have like 40thousand records. I want to calculate how many times
king's burger have been mentioned in the messages of all documents.
I am not able to make query for this, I now its trivial stuff but I am
quite new in elastic search. Your help is highly appreciated.

--


(ali ilyas) #3

Thanks Sushant , it worked fine.

On Thursday, September 20, 2012 9:47:49 PM UTC+2, Sushant Shankar wrote:

Hi Ali,

If your index name is bigData, and the structure of the document is as you
described, the count query would look something like this:

curl -XGET 'http://localhost:9200/bigData/_search?' -d '
{
"query": {
"query_string": {
"fields": ["message"],
"query": ""king's burger""
}
}
}'

You should see the count of this under response's hits then total

For reference, check out
http://www.elasticsearch.org/guide/reference/api/search/request-body.html

Try the Count API:
http://www.elasticsearch.org/guide/reference/api/count.html

On Thursday, September 20, 2012 12:29:25 PM UTC-7, ali ilyas wrote:

Hi,
I have indexed data on elastic search node. The structure of document is
it has two fields namely , name and message. In message it contains text.
Now I want to count the occurance of some particular phrase that occurs in
messages.
Like http://localhost:9200/big/data/INDEXES OF DOCUMENTS
The structure of document is
{
"name":"xyz",
"message":"i like to eat king's burger. I go there quite often"
}
Now I have like 40thousand records. I want to calculate how many times
king's burger have been mentioned in the messages of all documents.
I am not able to make query for this, I now its trivial stuff but I am
quite new in elastic search. Your help is highly appreciated.

--


(system) #4