Hello
I'm quite new on elasticsearch.
I made a form who query an elasticsearch document for getting the datas.
In the form there is mutiple input :
image_yes : checkbox
NAME : string
COLLECTION : string
CATALOGNUMBER:string
RECORDNUMBER: string
LOCALISATION: string
EVENTID : integer
event_date_start: year integer
event_date_end: year integer
the search is general: on all the fields of the document
I made many simples queries who works but i can't make a complexe one
working with AND and RANGE. All the exemples i see use "match_all:{}".
I also need the use of "*" and "?" in the query.
this work ok:
curl -XGET 'localhost:9200/donnees/specimens/_search?pretty=true' -d '{
"fields" : ["EVENTID", "CATALOGNUMBER", "RECORDNUMBER"],
"query" : {
"query_string" : {
"query" : "CATALOGNUMBER:P000023*"
}
}
}'
curl -XGET 'localhost:9200/donnees/specimens/_search?pretty=true' -d '{
"fields" : ["EVENTID", "CATALOGNUMBER", "RECORDNUMBER"],
"query" : {
"filtered" : {
"filter" : {
"range":{"EVENTID": {"from" : 36,
"to" : 50,
"include_lower" : true,
"include_upper" : false}
}
}
}
}
}'
this working ok too:
curl -XGET 'localhost:9200/donnees/specimens/_search?pretty=true' -d '{
"fields" : ["EVENTID", "CATALOGNUMBER", "RECORDNUMBER"],
"query" : {
"bool" : {
"must" : [
{
"query_string":{"query" : "CATALOGNUMBER:P000023*"}
},
{
"query_string":{"query" :
"RECORDNUMBER:recordnumber236*"}
}
]
}
},
"highlight": {"pre_tags": [""], "post_tags": [""],
"fields": {"*": {}}},
"facets": {
"lifestage": {"terms": { "field": "LIFESTAGE", "size": 20}},
"sex": {"terms": {"field": "SEX", "size": 20}},
"continent": {"terms": {"field": "CONTINENT", "size": 20}},
"institutioncode": {"terms": {"field": "INSTITUTIONCODE", "size":
20 }}
}
}'
*trying to merge but fail : *
I need that the facets are made with the results so i can't use "filtering"
if i understand good.
I try many syntaxes but nothink good.
(error)
curl -XGET 'localhost:9200/donnees/specimens/_search?pretty=true' -d '{
"fields" : ["EVENTID", "CATALOGNUMBER", "RECORDNUMBER"],
"query" : {
"filtered" : {
"filter" : {
"range":{"EVENTID": {"from" : 36,
"to" : 50,
"include_lower" : true,
"include_upper" : false}
}
},
"query_string" : {
"query" : "CATALOGNUMBER:P000023*"
}
}
},
"highlight": {"pre_tags": [""], "post_tags": [""],
"fields": {"": {}}},
"facets": {
"lifestage": {"terms": { "field": "LIFESTAGE", "size": 20}},
"sex": {"terms": {"field": "SEX", "size": 20}},
"continent": {"terms": {"field": "CONTINENT", "size": 20}},
"institutioncode": {"terms": {"field": "INSTITUTIONCODE", "size":
20 }}
}
}'
error :
curl -XGET 'localhost:9200/donnees/specimens/_search?pretty=true' -d '{
"fields" : ["EVENTID", "CATALOGNUMBER", "RECORDNUMBER"],
"query" : {
"filtered" : {
"filter" : {
"range":{"EVENTID": {"from" : 36,
"to" : 50,
"include_lower" : true,
"include_upper" : false}
}
}
},
"query_string" : { "query" : "CATALOGNUMBER:P000023" }
},
"highlight": {"pre_tags": [""], "post_tags": [""],
"fields": {"*": {}}},
"facets": {
"lifestage": {"terms": { "field": "LIFESTAGE", "size": 20}},
"sex": {"terms": {"field": "SEX", "size": 20}},
"continent": {"terms": {"field": "CONTINENT", "size": 20}},
"institutioncode": {"terms": {"field": "INSTITUTIONCODE", "size":
20 }}
}
}'
how can i put a AND query with Range please ?
I whish somethink like this in pseudo sql:
select * from document where :
image_yes is true
AND NAME : "name"
AND COLLECTION : "collection*"
AND CATALOGNUMBER:"catalognumber*"
AND RECORDNUMBER:"recordnumber*"
AND LOCALISATION: "localisation"
AND
"range":{"EVENTID": {"from" : 36, "include_lower" : true
}
AND
"range":{" event_date": {"from" : event_date_start,
"to" : event_data_end,
"include_lower" : true,
"include_upper" : false}
}
Many thanks
Alain
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/2d8f34dd-37bf-4850-8bc3-cd4b84ac02db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.