Filter data from field name on elasticsearch-PHP

@Camilo_Sierra: I tried this one too.Data is returning.But still i cant see the difference.

[quote="Camilo_Sierra, post:20, topic:268"]
"term": {
"phone_mobile": 465
}
},
{
"term": {

  "phone_home": 465
                }

[/quote] In here you should have "" for numbers like this.

      "phone_home": "465"

Otherwise without quotes, will return an error.

i will tried to explain with sql terms, maybe it will be easy to understand!
we have a should because it can be p_mobile or p_home (sql OR) but inside the "should" query for one condition we will add a must (is inside OR query add AND options) bool allow us to encapsulate the exist filter and the term filter.

the first query that i send you is the literally traduction of :

the exist check if the field is empty or not and the terms if the value correspond.

but we can do easier, in the last query we forget php and think in elasticsearch mode, we like to get all the documents that had p_mobile or p_home with a value of 465, so we don't need to know if exist or not because the only think that is important is that my fields correspond to my value 465.

normaly if your mapping is defined as a integer you dont need to use the " " ! check the type for phone_home, and phone_mobile and is not at integer defined in your template or mapping file and reindex

http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html

@Camilo_Sierra:ok now i get it.so can we do a search using AND ,OR operators?

phone_mobile=456 AND first_name=ABC

kind of queries?

technically yes you can use and/or, but the problem is that "and"/"or" dont use bitsets, you boost your query performance using bitsets.

more information :
https://www.elastic.co/blog/all-about-elasticsearch-filter-bitsets

Please help me. I am using php 5.5 and Elasticsearch 2.1. I want to do ranking among history. But my date filter does not work correctly.

I am getting accurate results when I made query only between the dates.However, I am not getting accurate results when I made query with date mont, day and hour.

For example :

http://10.0.2.15:8080/filter.php?my_date_try&my_date_lte=2017/12/3123:59:59&my_date_gte=2016/01/0100:00:00

Result is not correct.

Example 2:

http://10.0.2.15:8080/filter.php?my_date_try&my_date_lte=2017&my_date_gte=2016

Result is correct.

My date mapping :

$myTypeMapping['properties']['my_date']['type']='date';

$myTypeMapping['properties']['my_date']['index']='not_analyzed';

$myTypeMapping['properties']['my_date']['format']='yyyy/MM/dd HH:mm:ss';
My date filter :

unset($filter_my_date);

if(isset($_GET[my_date_try])){

$filter_my_date['range']['my_date']['lte']=$_GET['my_date_lte'];

$filter_my_date['range']['my_date']['gte']=$_GET['my_date_gte'];

$filter_my_date['range']['my_date']['format']='yyyy/MM/dd HH:mm:ss';
}

if(is_array($filter_my_date)){

$searchParams['body']['query']['bool']['must']=$filter_my_date;

}

Please start your own thread.