Mixing Filters

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 elasticsearch+unsubscribe@googlegroups.com.
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.

What is the error?

David

Le 12 déc. 2014 à 21:04, Bruno Kamiche bkamiche@gmail.com a écrit :

Hello, I'm testing Elasticsearch 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 elasticsearch+unsubscribe@googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1E9AF9D7-6495-44F9-A77B-D96D6BC74A95%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

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 bkamiche@gmail.com a écrit :

Hello, I'm testing Elasticsearch 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 elasticsearch+unsubscribe@googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3FCCAC5F-8D32-414A-9901-850267973ED6%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

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 <bkam...@gmail.com <javascript:>>
a écrit :

Hello, I'm testing Elasticsearch 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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/be4ca3a2-081f-458a-a006-8d8e80ef23e5%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/be4ca3a2-081f-458a-a006-8d8e80ef23e5%40googlegroups.com?utm_medium=email&utm_source=footer
.
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/915649e8-57b3-4315-90c6-bba820665c00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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 Elasticsearch 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 bkam...@gmail.com a écrit :

Hello, I'm testing Elasticsearch 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 elasticsearc...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/be4ca3a2-081f-458a-a006-8d8e80ef23e5%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/be4ca3a2-081f-458a-a006-8d8e80ef23e5%40googlegroups.com?utm_medium=email&utm_source=footer
.
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 elasticsearch+unsubscribe@googlegroups.com.
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.

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 bkamiche@gmail.com 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 Elasticsearch 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 bkam...@gmail.com a écrit :

Hello, I'm testing Elasticsearch 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 elasticsearc...@googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/30F77D58-3144-45CC-8540-471DE55BC716%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

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 <bkam...@gmail.com <javascript:>>
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 Elasticsearch 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 bkam...@gmail.com a écrit :

Hello, I'm testing Elasticsearch 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 elasticsearc...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/be4ca3a2-081f-458a-a006-8d8e80ef23e5%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/be4ca3a2-081f-458a-a006-8d8e80ef23e5%40googlegroups.com?utm_medium=email&utm_source=footer
.
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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/5ac37c0e-69a7-4ffd-b211-497fb88b7e23%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/5ac37c0e-69a7-4ffd-b211-497fb88b7e23%40googlegroups.com?utm_medium=email&utm_source=footer
.
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/87b1d3a8-a7a6-4b84-9928-bbcd6e4094e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

So a date with this format should work.

David

Le 12 déc. 2014 à 21:35, Bruno Kamiche bkamiche@gmail.com a écrit :

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 bkam...@gmail.com 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 Elasticsearch 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 bkam...@gmail.com a écrit :

Hello, I'm testing Elasticsearch 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 elasticsearc...@googlegroups.com.
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 elasticsearc...@googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/87b1d3a8-a7a6-4b84-9928-bbcd6e4094e8%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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8B7CFD52-8EDF-4D77-BF57-2BFEEA4DC212%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

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 bkam...@gmail.com 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 Elasticsearch 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 bkam...@gmail.com a écrit :

Hello, I'm testing Elasticsearch 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 elasticsearc...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/be4ca3a2-081f-458a-a006-8d8e80ef23e5%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/be4ca3a2-081f-458a-a006-8d8e80ef23e5%40googlegroups.com?utm_medium=email&utm_source=footer
.
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 elasticsearc...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/5ac37c0e-69a7-4ffd-b211-497fb88b7e23%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/5ac37c0e-69a7-4ffd-b211-497fb88b7e23%40googlegroups.com?utm_medium=email&utm_source=footer
.
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 elasticsearch+unsubscribe@googlegroups.com.
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.

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

David

Le 12 déc. 2014 à 21:39, Bruno Kamiche bkamiche@gmail.com 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 bkam...@gmail.com 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 Elasticsearch 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 bkam...@gmail.com a écrit :

Hello, I'm testing Elasticsearch 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 elasticsearc...@googlegroups.com.
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 elasticsearc...@googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
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.

I think there are a lot of problems about range filter date. I didn't solve this problem. Is there someone who can solve?

Hijacking old threads won't help you. Please keep your questions in Date format incorrect results