In the above mapping I would like to filter search results with a
particular company_name. The company_name can be Null also (This is just an
example). As you can see the comments type doesn't have company_name field.
So, I have to use exists filter also.
search_key = 'test'
Tire.search [account_1] do
query do
filtered do
query { string search_key }
filter :or, { :not => { :exists => { :field =>
:company_name } } },
{ :term => { :company_name => 'test' } }
end
end
end
The above filter checks just the existence of company_name field or filters
exact company_name if exists. I want to add null_value check along with
this if company_name field exists.
I want to avoid the results where company_name is nil for the user type
along with the above filter.
In the above mapping I would like to filter search results with a
particular company_name. The company_name can be Null also (This is just an
example). As you can see the comments type doesn't have company_name field.
So, I have to use exists filter also.
search_key = 'test'
Tire.search [account_1] do
query do
filtered do
query { string search_key }
filter :or, { :not => { :exists => { :field => :company_name } } },
{ :term => { :company_name => 'test' } }
end
end
end
The above filter checks just the existence of company_name field or
filters exact company_name if exists. I want to add null_value check along
with this if company_name field exists.
I want to avoid the results where company_name is nil for the user type
along with the above filter.
First of all sorry for asking the question using the Tire gem functions. I
should have posted the gist or curl example in elasticsearch group.
Thanks for the reply Igor.
Even missing filter is avoiding null values. Came to know that a field with
a null value simply isn't even stored.
Finally achieved it with the help of suggestion given by Tire gem owner
Karmi. I had to replace the null value in the document with mapping via the
null_value option, and then used the same filter.
On Tuesday, January 15, 2013 5:06:58 AM UTC+5:30, Igor Motov wrote:
In the above mapping I would like to filter search results with a
particular company_name. The company_name can be Null also (This is just an
example). As you can see the comments type doesn't have company_name field.
So, I have to use exists filter also.
search_key = 'test'
Tire.search [account_1] do
query do
filtered do
query { string search_key }
filter :or, { :not => { :exists => { :field => :company_name } } },
{ :term => { :company_name => 'test' } }
end
end
end
The above filter checks just the existence of company_name field or
filters exact company_name if exists. I want to add null_value check along
with this if company_name field exists.
I want to avoid the results where company_name is nil for the user type
along with the above filter.
The original requirement is that, I have documents one with the field
company_name - Test, other with out the field company_name and another with
company_name as NULL.
Now, from these documents, I need the results where company_name = Test or
company_name field doesn't exist. I don't need the document with
company_name = NULL.
On Tuesday, January 15, 2013 5:06:58 AM UTC+5:30, Igor Motov wrote:
In the above mapping I would like to filter search results with a
particular company_name. The company_name can be Null also (This is just an
example). As you can see the comments type doesn't have company_name field.
So, I have to use exists filter also.
search_key = 'test'
Tire.search [account_1] do
query do
filtered do
query { string search_key }
filter :or, { :not => { :exists => { :field => :company_name } } },
{ :term => { :company_name => 'test' } }
end
end
end
The above filter checks just the existence of company_name field or
filters exact company_name if exists. I want to add null_value check along
with this if company_name field exists.
I want to avoid the results where company_name is nil for the user type
along with the above filter.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.