electic
(electic)
November 11, 2011, 11:28pm
1
I have a document like this:
curl -XPOST 192.168.8.231:9200/documents -d '{
"settings" : {
"number_of_shards" : 20,
"number_of_replicas" : 0
},
"mappings" : {
"document" : {
"_source" : { "enabled" : false },
"properties" : {
"record_id" : { "type" : "string", "index" :
"analyzed", "store" : "no" },
"platform" : { "type" : "string", "index" :
"analyzed", "store" : "no" },
"tags" : { "type" : "string", "index" : "analyzed",
"store" : "no" },
"utimestamp" : { "type" : "long", "index" :
"analyzed", "store" : "no" },
"created_at" : { "type" : "date", "index" :
"analyzed", "store" : "no" }
}
}
}
}'
and I am trying to do a range query for records over a certain date:
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"term" : { "tags" : "ass" },
"fitler" : {
"range" : {
"created_at" : {
"gte" : 1321050744
}
}
}
}
}'
For the sake of simplicity, I have gone ahead and put a utimestamp and
also a created at in the format of: %Y%m%dT%H:%M:%S.%i. When I try
running the above range query, it gives an error, What is the proper
syntax to do a range query? Any help is appreciated!
vinny
(vinny)
November 12, 2011, 4:26am
2
Was the ranger filter copied exactly from what you were working from? I
ask because "filter" is misspelled. Also, not sure if you want to use the
created_at for the filter, I would think you would want to use the
utimestamp.
egaumer
(egaumer)
November 12, 2011, 4:52am
3
You should use a filteredQuery.
{
"filtered" : {
"query" : {
"term" : { "tags" : "ass" }
},
"filter" : {
"numeric_range" : {
"created_at" : {
"gte" : 1321050744
}
}
}
}
}
electic
(electic)
November 12, 2011, 6:58pm
4
Thanks everyone for your help! So I have one more question. So this is
what I have now:
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{"match_all":{}},
"filter" : {
"and" : [{"term" : {"tags" : "chat car"}}, {"range" :
{"utimestamp" : {"gte" : 1321085190}}}]
},
"sort" : {"created_at" : "desc" }
},
"size" : 500
}
}'
and it works if you do it for one keyword. However, what if you want
two keywords, say, "chat car" which there are records for but it
returns nothing back. What is the best way to to do that?
On Nov 11, 8:52 pm, egaumer egau...@gmail.com wrote:
You should use a filteredQuery.
{
"filtered" : {
"query" : {
"term" : { "tags" : "ass" }
},
"filter" : {
"numeric_range" : {
"created_at" : {
"gte" : 1321050744
}
}
}
}
}
electic
(electic)
November 12, 2011, 7:04pm
5
I think I got it, if anyone else needs help:
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{
"query_string" : {
"query" : "chat car",
"default_operator" : "AND"
}
},
"filter" : {
"and" : [{"range" : {"utimestamp" : {"gte" :
1321085190}}}]
},
"sort" : {"created_at" : "desc" }
},
"size" : 500
}
}'
On Nov 12, 10:58 am, electic elec...@gmail.com wrote:
Thanks everyone for your help! So I have one more question. So this is
what I have now:
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{"match_all":{}},
"filter" : {
"and" : [{"term" : {"tags" : "chat car"}}, {"range" :
{"utimestamp" : {"gte" : 1321085190}}}]
},
"sort" : {"created_at" : "desc" }
},
"size" : 500
}
}'
and it works if you do it for one keyword. However, what if you want
two keywords, say, "chat car" which there are records for but it
returns nothing back. What is the best way to to do that?
On Nov 11, 8:52 pm, egaumer egau...@gmail.com wrote:
You should use a filteredQuery.
{
"filtered" : {
"query" : {
"term" : { "tags" : "ass" }
},
"filter" : {
"numeric_range" : {
"created_at" : {
"gte" : 1321050744
}
}
}
}
}
kimchy
(Shay Banon)
November 13, 2011, 8:52am
6
Btw, your sort is not on the correct level and size are not on the correct
level, they should be on hte same level as the outermost "query".
On Sat, Nov 12, 2011 at 8:58 PM, electic electic@gmail.com wrote:
Thanks everyone for your help! So I have one more question. So this is
what I have now:
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{"match_all":{}},
"filter" : {
"and" : [{"term" : {"tags" : "chat car"}}, {"range" :
{"utimestamp" : {"gte" : 1321085190}}}]
},
"sort" : {"created_at" : "desc" }
},
"size" : 500
}
}'
and it works if you do it for one keyword. However, what if you want
two keywords, say, "chat car" which there are records for but it
returns nothing back. What is the best way to to do that?
On Nov 11, 8:52 pm, egaumer egau...@gmail.com wrote:
You should use a filteredQuery.
{
"filtered" : {
"query" : {
"term" : { "tags" : "ass" }
},
"filter" : {
"numeric_range" : {
"created_at" : {
"gte" : 1321050744
}
}
}
}
}
electic
(electic)
November 13, 2011, 11:44am
7
Oh no, so it should be like this?
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{
"query_string" : {
"query" : "chat car",
"default_operator" : "AND"
},
"sort" : {"created_at" : "desc" }
},
"filter" : {
"and" : [{"range" : {"utimestamp" : {"gte" :
1321085190}}}]
}
},
"size" : 500
}
}'
On Nov 13, 12:52 am, Shay Banon kim...@gmail.com wrote:
Btw, your sort is not on the correct level and size are not on the correct
level, they should be on hte same level as the outermost "query".
On Sat, Nov 12, 2011 at 8:58 PM, electic elec...@gmail.com wrote:
Thanks everyone for your help! So I have one more question. So this is
what I have now:
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{"match_all":{}},
"filter" : {
"and" : [{"term" : {"tags" : "chat car"}}, {"range" :
{"utimestamp" : {"gte" : 1321085190}}}]
},
"sort" : {"created_at" : "desc" }
},
"size" : 500
}
}'
and it works if you do it for one keyword. However, what if you want
two keywords, say, "chat car" which there are records for but it
returns nothing back. What is the best way to to do that?
On Nov 11, 8:52 pm, egaumer egau...@gmail.com wrote:
You should use a filteredQuery.
{
"filtered" : {
"query" : {
"term" : { "tags" : "ass" }
},
"filter" : {
"numeric_range" : {
"created_at" : {
"gte" : 1321050744
}
}
}
}
}
kimchy
(Shay Banon)
November 13, 2011, 1:34pm
8
No, it should be on the same level as the top most query, the search
request looks something like this:
{
"query" : { ... },
"size" : 100,
"sort" : {...}
}
On Sun, Nov 13, 2011 at 1:44 PM, electic electic@gmail.com wrote:
Oh no, so it should be like this?
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{
"query_string" : {
"query" : "chat car",
"default_operator" : "AND"
},
"sort" : {"created_at" : "desc" }
},
"filter" : {
"and" : [{"range" : {"utimestamp" : {"gte" :
1321085190}}}]
}
},
"size" : 500
}
}'
On Nov 13, 12:52 am, Shay Banon kim...@gmail.com wrote:
Btw, your sort is not on the correct level and size are not on the
correct
level, they should be on hte same level as the outermost "query".
On Sat, Nov 12, 2011 at 8:58 PM, electic elec...@gmail.com wrote:
Thanks everyone for your help! So I have one more question. So this is
what I have now:
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{"match_all":{}},
"filter" : {
"and" : [{"term" : {"tags" : "chat car"}}, {"range" :
{"utimestamp" : {"gte" : 1321085190}}}]
},
"sort" : {"created_at" : "desc" }
},
"size" : 500
}
}'
and it works if you do it for one keyword. However, what if you want
two keywords, say, "chat car" which there are records for but it
returns nothing back. What is the best way to to do that?
On Nov 11, 8:52 pm, egaumer egau...@gmail.com wrote:
You should use a filteredQuery.
{
"filtered" : {
"query" : {
"term" : { "tags" : "ass" }
},
"filter" : {
"numeric_range" : {
"created_at" : {
"gte" : 1321050744
}
}
}
}
}
electic
(electic)
November 13, 2011, 11:23pm
9
Thanks Shay. You are right. It was nested wrong. I have one more
question for you guys. I have a query like this
(keyword1 | keyword2) keyword3
I am putting this into my query_string->query part of the JSON with a
default operator of AND. My guess is that the system is not
recognizing the pipe symbol for some reason. How would I use the pipe
symbol in the query?
On Nov 13, 5:34 am, Shay Banon kim...@gmail.com wrote:
No, it should be on the same level as the top most query, the search
request looks something like this:
{
"query" : { ... },
"size" : 100,
"sort" : {...}
}
On Sun, Nov 13, 2011 at 1:44 PM, electic elec...@gmail.com wrote:
Oh no, so it should be like this?
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{
"query_string" : {
"query" : "chat car",
"default_operator" : "AND"
},
"sort" : {"created_at" : "desc" }
},
"filter" : {
"and" : [{"range" : {"utimestamp" : {"gte" :
1321085190}}}]
}
},
"size" : 500
}
}'
On Nov 13, 12:52 am, Shay Banon kim...@gmail.com wrote:
Btw, your sort is not on the correct level and size are not on the
correct
level, they should be on hte same level as the outermost "query".
On Sat, Nov 12, 2011 at 8:58 PM, electic elec...@gmail.com wrote:
Thanks everyone for your help! So I have one more question. So this is
what I have now:
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{"match_all":{}},
"filter" : {
"and" : [{"term" : {"tags" : "chat car"}}, {"range" :
{"utimestamp" : {"gte" : 1321085190}}}]
},
"sort" : {"created_at" : "desc" }
},
"size" : 500
}
}'
and it works if you do it for one keyword. However, what if you want
two keywords, say, "chat car" which there are records for but it
returns nothing back. What is the best way to to do that?
On Nov 11, 8:52 pm, egaumer egau...@gmail.com wrote:
You should use a filteredQuery.
{
"filtered" : {
"query" : {
"term" : { "tags" : "ass" }
},
"filter" : {
"numeric_range" : {
"created_at" : {
"gte" : 1321050744
}
}
}
}
}
User term OR.
(keyword1 OR keyword2) keyword3
2011/11/13 electic electic@gmail.com :
Thanks Shay. You are right. It was nested wrong. I have one more
question for you guys. I have a query like this
(keyword1 | keyword2) keyword3
I am putting this into my query_string->query part of the JSON with a
default operator of AND. My guess is that the system is not
recognizing the pipe symbol for some reason. How would I use the pipe
symbol in the query?
On Nov 13, 5:34 am, Shay Banon kim...@gmail.com wrote:
No, it should be on the same level as the top most query, the search
request looks something like this:
{
"query" : { ... },
"size" : 100,
"sort" : {...}
}
On Sun, Nov 13, 2011 at 1:44 PM, electic elec...@gmail.com wrote:
Oh no, so it should be like this?
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{
"query_string" : {
"query" : "chat car",
"default_operator" : "AND"
},
"sort" : {"created_at" : "desc" }
},
"filter" : {
"and" : [{"range" : {"utimestamp" : {"gte" :
1321085190}}}]
}
},
"size" : 500
}
}'
On Nov 13, 12:52 am, Shay Banon kim...@gmail.com wrote:
Btw, your sort is not on the correct level and size are not on the
correct
level, they should be on hte same level as the outermost "query".
On Sat, Nov 12, 2011 at 8:58 PM, electic elec...@gmail.com wrote:
Thanks everyone for your help! So I have one more question. So this is
what I have now:
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{"match_all":{}},
"filter" : {
"and" : [{"term" : {"tags" : "chat car"}}, {"range" :
{"utimestamp" : {"gte" : 1321085190}}}]
},
"sort" : {"created_at" : "desc" }
},
"size" : 500
}
}'
and it works if you do it for one keyword. However, what if you want
two keywords, say, "chat car" which there are records for but it
returns nothing back. What is the best way to to do that?
On Nov 11, 8:52 pm, egaumer egau...@gmail.com wrote:
You should use a filteredQuery.
{
"filtered" : {
"query" : {
"term" : { "tags" : "ass" }
},
"filter" : {
"numeric_range" : {
"created_at" : {
"gte" : 1321050744
}
}
}
}
}
--
Gustavo Maia
electic
(electic)
November 13, 2011, 11:54pm
11
I know that but is there a way to support the pipe symbol as an OR?
On Nov 13, 3:52 pm, Gustavo Maia gustavobbm...@gmail.com wrote:
User term OR.
(keyword1 OR keyword2) keyword3
2011/11/13 electic elec...@gmail.com :
Thanks Shay. You are right. It was nested wrong. I have one more
question for you guys. I have a query like this
(keyword1 | keyword2) keyword3
I am putting this into my query_string->query part of the JSON with a
default operator of AND. My guess is that the system is not
recognizing the pipe symbol for some reason. How would I use the pipe
symbol in the query?
On Nov 13, 5:34 am, Shay Banon kim...@gmail.com wrote:
No, it should be on the same level as the top most query, the search
request looks something like this:
{
"query" : { ... },
"size" : 100,
"sort" : {...}
}
On Sun, Nov 13, 2011 at 1:44 PM, electic elec...@gmail.com wrote:
Oh no, so it should be like this?
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{
"query_string" : {
"query" : "chat car",
"default_operator" : "AND"
},
"sort" : {"created_at" : "desc" }
},
"filter" : {
"and" : [{"range" : {"utimestamp" : {"gte" :
1321085190}}}]
}
},
"size" : 500
}
}'
On Nov 13, 12:52 am, Shay Banon kim...@gmail.com wrote:
Btw, your sort is not on the correct level and size are not on the
correct
level, they should be on hte same level as the outermost "query".
On Sat, Nov 12, 2011 at 8:58 PM, electic elec...@gmail.com wrote:
Thanks everyone for your help! So I have one more question. So this is
what I have now:
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{"match_all":{}},
"filter" : {
"and" : [{"term" : {"tags" : "chat car"}}, {"range" :
{"utimestamp" : {"gte" : 1321085190}}}]
},
"sort" : {"created_at" : "desc" }
},
"size" : 500
}
}'
and it works if you do it for one keyword. However, what if you want
two keywords, say, "chat car" which there are records for but it
returns nothing back. What is the best way to to do that?
On Nov 11, 8:52 pm, egaumer egau...@gmail.com wrote:
You should use a filteredQuery.
{
"filtered" : {
"query" : {
"term" : { "tags" : "ass" }
},
"filter" : {
"numeric_range" : {
"created_at" : {
"gte" : 1321050744
}
}
}
}
}
--
Gustavo Maia
I don;t know i only use symbol OR.
2011/11/13 electic electic@gmail.com :
I know that but is there a way to support the pipe symbol as an OR?
On Nov 13, 3:52 pm, Gustavo Maia gustavobbm...@gmail.com wrote:
User term OR.
(keyword1 OR keyword2) keyword3
2011/11/13 electic elec...@gmail.com :
Thanks Shay. You are right. It was nested wrong. I have one more
question for you guys. I have a query like this
(keyword1 | keyword2) keyword3
I am putting this into my query_string->query part of the JSON with a
default operator of AND. My guess is that the system is not
recognizing the pipe symbol for some reason. How would I use the pipe
symbol in the query?
On Nov 13, 5:34 am, Shay Banon kim...@gmail.com wrote:
No, it should be on the same level as the top most query, the search
request looks something like this:
{
"query" : { ... },
"size" : 100,
"sort" : {...}
}
On Sun, Nov 13, 2011 at 1:44 PM, electic elec...@gmail.com wrote:
Oh no, so it should be like this?
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{
"query_string" : {
"query" : "chat car",
"default_operator" : "AND"
},
"sort" : {"created_at" : "desc" }
},
"filter" : {
"and" : [{"range" : {"utimestamp" : {"gte" :
1321085190}}}]
}
},
"size" : 500
}
}'
On Nov 13, 12:52 am, Shay Banon kim...@gmail.com wrote:
Btw, your sort is not on the correct level and size are not on the
correct
level, they should be on hte same level as the outermost "query".
On Sat, Nov 12, 2011 at 8:58 PM, electic elec...@gmail.com wrote:
Thanks everyone for your help! So I have one more question. So this is
what I have now:
curl -XGET 192.168.8.231:9200/documents/_search -d '{
"query" : {
"filtered" : {
"query":{"match_all":{}},
"filter" : {
"and" : [{"term" : {"tags" : "chat car"}}, {"range" :
{"utimestamp" : {"gte" : 1321085190}}}]
},
"sort" : {"created_at" : "desc" }
},
"size" : 500
}
}'
and it works if you do it for one keyword. However, what if you want
two keywords, say, "chat car" which there are records for but it
returns nothing back. What is the best way to to do that?
On Nov 11, 8:52 pm, egaumer egau...@gmail.com wrote:
You should use a filteredQuery.
{
"filtered" : {
"query" : {
"term" : { "tags" : "ass" }
},
"filter" : {
"numeric_range" : {
"created_at" : {
"gte" : 1321050744
}
}
}
}
}
--
Gustavo Maia
--
Gustavo Maia