I don't know. You should create a full SENSE recreation and GIST it.

David

> Le 12 déc. 2014 à 21:39, Bruno Kamiche <[email protected]> a écrit :
> 
> I'm using the range as follows:
> 
>                                                         "range" : {
>                                                                 "fecha" : {
>                                                                         "gte" 
> : "2012-08-01 00:00:00",
>                                                                         "lte" 
> : "2012-08-31 23:59:59"
>                                                                 }
>                                                         }
> 
> 
> But although I dont get an error, the returned fields are not complying with 
> the range....
> 
>> On Friday, December 12, 2014 3:35:23 PM UTC-5, Bruno Kamiche wrote:
>> This is my mapping
>> 
>>                     'fecha' => [
>>                         'type' => 'date',
>>                         'format' => 'YYYY-mm-dd HH:mm:ss'
>>                     ]
>> 
>> 
>>> On Friday, December 12, 2014 3:33:22 PM UTC-5, David Pilato wrote:
>>> Text should be fine. But are you sure you defined the field as date in 
>>> mapping?
>>> With the right format?
>>> 
>>> David
>>> 
>>>> Le 12 déc. 2014 à 21:15, Bruno Kamiche <[email protected]> a écrit :
>>>> 
>>>> I think I figured it out, I needed an extra set of curly braces
>>>> 
>>>>                         "filter" : {
>>>>                                 "bool" :  {
>>>>                                         "must" : [
>>>>                                                 {
>>>>                                                         "range" : {
>>>>                                                                 "fecha" : {
>>>>                                                                         
>>>> "gte" : 1325394000,
>>>>                                                                         
>>>> "lte" : 1356930000
>>>>                                                                 }
>>>>                                                         }
>>>>                                                 },
>>>>                                                 {
>>>>                                                         "term" : { 
>>>> "aq_industryid" : 1 }
>>>>                                                 },
>>>>                                                 {
>>>>                                                         "term" : { 
>>>> "aq_clientid" : 1 }
>>>>                                                 },
>>>>                                                 {
>>>>                                                         "term" : { "ntipo" 
>>>> : [5] }
>>>>                                                 }
>>>>                                         ]
>>>>                                 }
>>>>                         }
>>>> 
>>>> Now the query runs, but it does not yield the expected results, maybe you 
>>>> can help me with this
>>>> 
>>>> When I index the data, the field "fecha" is declared as a date field, with 
>>>> format "YYYY-mm-dd HH:mm:ss", when I query elastic search I see the 
>>>> correct dates in the retrieved information, now I need to filter upon this 
>>>> data with a range of dates, how shall I express the range values, as text 
>>>> or as a unixtime ?
>>>> 
>>>> I've tried both and although theres data that should comply elastic does 
>>>> not return records.
>>>> 
>>>> 
>>>> 
>>>>> On Friday, December 12, 2014 3:08:51 PM UTC-5, Bruno Kamiche wrote:
>>>>> I changed the filter to this:
>>>>> 
>>>>>                         "filter" : {
>>>>>                                 "bool" :  {
>>>>>                                         "must" : [
>>>>>                                                 "range" : {
>>>>>                                                         "fecha" : {
>>>>>                                                                 "gte" : 
>>>>> "1325394000",
>>>>>                                                                 "lte" : 
>>>>> "1356930000"
>>>>>                                                         }
>>>>>                                                 },
>>>>>                                                 {
>>>>>                                                         "term" : { 
>>>>> "aq_industryid" : 1 }
>>>>>                                                 },
>>>>>                                                 {
>>>>>                                                         "term" : { 
>>>>> "aq_clientid" : 1 }
>>>>>                                                 },
>>>>>                                                 {
>>>>>                                                         "term" : { 
>>>>> "ntipo" : [5] }
>>>>>                                                 }
>>>>>                                         ]
>>>>>                                 }
>>>>>                         }
>>>>> 
>>>>> But it keeps the error:
>>>>> 
>>>>> PHP Fatal error:  Uncaught exception 
>>>>> 'Guzzle\Http\Exception\ClientErrorResponseException' with message 'Client 
>>>>> error response
>>>>> [status code] 400
>>>>> [reason phrase] Bad Request
>>>>> [url] http://localhost:9200/quantico_index/quantico_type/_search' in 
>>>>> /root/vendor/guzzle/http/Guzzle/Http/Exception/BadResponseException.php:43
>>>>> Stack trace:
>>>>> #0 /root/vendor/guzzle/http/Guzzle/Http/Message/Request.php(145): 
>>>>> Guzzle\Http\Exception\BadResponseException::factory(Object(Guzzle\Http\Message\EntityEnclosingRequest),
>>>>>  Object(Guzzle\Http\Message\Response))
>>>>> #1 [internal function]: 
>>>>> Guzzle\Http\Message\Request::onRequestError(Object(Guzzle\Common\Event), 
>>>>> 'request.error', 
>>>>> Object(Symfony\Component\EventDispatcher\EventDispatcher))
>>>>> #2 
>>>>> /root/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php(164):
>>>>>  call_user_func(Array, Object(Guzzle\Common\Event), 'request.error', 
>>>>> Object(Symfony\Component\EventDispatcher\EventDispatcher))
>>>>> #3 
>>>>> /root/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php(53):
>>>>>  Symf in 
>>>>> /root/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/GuzzleConnection.php
>>>>>  on line 266
>>>>> 
>>>>> 
>>>>>> On Friday, December 12, 2014 3:06:47 PM UTC-5, David Pilato wrote:
>>>>>> Oh I see. Filter accepts only one filter. You should put your range 
>>>>>> inside the Must array.
>>>>>> 
>>>>>> David
>>>>>> 
>>>>>>> Le 12 déc. 2014 à 21:04, Bruno Kamiche <[email protected]> a écrit :
>>>>>>> 
>>>>>>> Hello, I'm testing elastic search and I need to apply different 
>>>>>>> filters, when I include the "range" filter I get an error and the query 
>>>>>>> is not executed, here's the json:
>>>>>>> 
>>>>>>> $json = '{
>>>>>>>         "size" : 10,
>>>>>>>         "from" : 0,
>>>>>>>         "sort" : [
>>>>>>>                 { "_timestamp" : { "order" : "desc" } },
>>>>>>>                 { "_score" : { "order" : "desc" } }
>>>>>>>         ],
>>>>>>>         "query" : {
>>>>>>>                 "filtered" : {
>>>>>>>                         "query" : {
>>>>>>>                                 "query_string" : {
>>>>>>>                                         "fields" : ["mytextfield"],
>>>>>>>                                         "query" : "my query string",
>>>>>>>                                         "default_operator" : "AND"
>>>>>>>                                 }
>>>>>>>                         },
>>>>>>>                         "filter" : {
>>>>>>>                                 "range" : {
>>>>>>>                                         "datefields" : {
>>>>>>>                                                 "gte" : "1325394000",
>>>>>>>                                                 "lte" : "1356930000"
>>>>>>>                                         }
>>>>>>>                                 },
>>>>>>>                                 "bool" :  {
>>>>>>>                                         "must" : [
>>>>>>>                                                 {
>>>>>>>                                                         "term" : { 
>>>>>>> "aq_industryid" : 1 }
>>>>>>>                                                 },
>>>>>>>                                                 {
>>>>>>>                                                         "term" : { 
>>>>>>> "aq_clientid" : 1 }
>>>>>>>                                                 },
>>>>>>>                                                 {
>>>>>>>                                                         "term" : { 
>>>>>>> "ntipo" : [5] }
>>>>>>>                                                 }
>>>>>>>                                         ]
>>>>>>>                                 }
>>>>>>>                         }
>>>>>>>                 }
>>>>>>> 
>>>>>>>         }
>>>>>>> }';
>>>>>>> 
>>>>>>> If I don't include the "range" filter, everything works fine (filtering 
>>>>>>> by the other fields, number of results, order, etc), what am I doing 
>>>>>>> wrong?
>>>>>>> 
>>>>>>> -- 
>>>>>>> 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/be4ca3a2-081f-458a-a006-8d8e80ef23e5%40googlegroups.com.
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>> 
>>>> -- 
>>>> 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/5ac37c0e-69a7-4ffd-b211-497fb88b7e23%40googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> 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/c7125662-eb03-4bd8-8446-bc3c0941f437%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/A6A53EED-9E47-439E-B390-E99E625EB3D6%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

Reply via email to