Java API for Elastic Search: Using wildcard to express filters like id<12* or a combinations of them

Hi,

I've a requirement that talks about implementing a wildcard filter with
operators like "<", "<=",">",">=","=","!=".
Ex: a<b* or a>=del*

I figured out that for

#1 "=", i could create a wilcard query and wrap it in a
QueryFilterBuilder and append it to other OrFilters or And Filters
*
*
#2 "!=", i could create a wildcard query, wrap it in a
QueryFilterBuilder, and then wrap the QueryFilterBuilder in a
NotFilterBuilder and then append the NotFilterBuilder to other OrFilters or
And Filters.

If anyone of you have worked on such a requirement, could you pls suggest a
solution.

In my application, the input is in the form (a<2&b>=7*)|c=test. I create
one single filter for the query and attach it to the match_all query.
Below is one such example
{
"from": 0,
"size": 10,
"query": {
"bool": {
"must": {
"filtered": {
"query": {"match_all": {}},
"filter": {"term": {"X.id": "*"}}
}
}
}
},
"fields": ["X.id",],"sort": [{"X.id": {"order": "asc"}}]
}

Thanks,
John

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

The first idea that come to my mind is to convert your user entry to Query String syntax: http://lucene.apache.org/core/4_1_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description

Then, pass it to a Match Query or a QueryString query.

But, note that using wildcards will slow your search.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 30 janv. 2013 à 22:56, john john2roll2@gmail.com a écrit :

Hi,

I've a requirement that talks about implementing a wildcard filter with operators like "<", "<=",">",">=","=","!=".
Ex: a<b* or a>=del*

I figured out that for

#1 "=", i could create a wilcard query and wrap it in a QueryFilterBuilder and append it to other OrFilters or And Filters

#2 "!=", i could create a wildcard query, wrap it in a QueryFilterBuilder, and then wrap the QueryFilterBuilder in a NotFilterBuilder and then append the NotFilterBuilder to other OrFilters or And Filters.

If anyone of you have worked on such a requirement, could you pls suggest a solution.

In my application, the input is in the form (a<2&b>=7*)|c=test. I create one single filter for the query and attach it to the match_all query.
Below is one such example
{
"from": 0,
"size": 10,
"query": {
"bool": {
"must": {
"filtered": {
"query": {"match_all": {}},
"filter": {"term": {"X.id": "*"}}
}
}
}
},
"fields": ["X.id",],"sort": [{"X.id": {"order": "asc"}}]
}

Thanks,
John

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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.