Something like Wildcard Filter?


(timscott) #1

Is there any way to filter a non-analyzed by "starts with?" Prefix
filter does work because it looks at each term whereas I need to look
at the whole value of the field. What I need is like the wildcard
query, except a filter. Is there any way to accomplish this? I spent
some time with the script filter but came up empty so far.


(Clinton Gormley) #2

On Wed, 2011-03-02 at 07:06 -0800, Tim Scott wrote:

Is there any way to filter a non-analyzed by "starts with?" Prefix
filter does work because it looks at each term whereas I need to look
at the whole value of the field. What I need is like the wildcard
query, except a filter. Is there any way to accomplish this? I spent
some time with the script filter but came up empty so far.

If I've understood you correctly, then the prefix filter should work.

Do you want to gist (http://www.elasticsearch.org/help) an example
showing what you're trying to achieve and why it doesn't work?

clint


(timscott) #3

Prefix filter does not work. I can gist if needed, but it's pretty
simple to explain. Assume three documents with values in a certain
field of:

"blue"
"blue red"
"red blue"

I need to filter documents where the field starts with "blue" (first
and second documents). A preview filter of "blue" will match all
three. That's because (it seems) it looks at terms (individual
words).

On Mar 2, 9:10 am, Clinton Gormley clin...@iannounce.co.uk wrote:

On Wed, 2011-03-02 at 07:06 -0800, Tim Scott wrote:

Is there any way to filter a non-analyzed by "starts with?" Prefix
filter does work because it looks at each term whereas I need to look
at the whole value of the field. What I need is like the wildcard
query, except a filter. Is there any way to accomplish this? I spent
some time with the script filter but came up empty so far.

If I've understood you correctly, then the prefix filter should work.

Do you want to gist (http://www.elasticsearch.org/help) an example
showing what you're trying to achieve and why it doesn't work?

clint


(Clinton Gormley) #4

On Wed, 2011-03-02 at 07:35 -0800, Tim Scott wrote:

Prefix filter does not work. I can gist if needed, but it's pretty
simple to explain. Assume three documents with values in a certain
field of:

"blue"
"blue red"
"red blue"

I need to filter documents where the field starts with "blue" (first
and second documents). A preview filter of "blue" will match all
three. That's because (it seems) it looks at terms (individual
words).

You said you wanted to use this on a non-analyzed field.

in which case, a prefix query works:

clint


(timscott) #5

I'm feeling stupid again. The field is question was mapped not-
analyzed. However somehow the mapping got changed. I fixed that, and
it works just as you said. Thanks for taking the time to prove it.

On Mar 2, 10:01 am, Clinton Gormley clin...@iannounce.co.uk wrote:

On Wed, 2011-03-02 at 07:35 -0800, Tim Scott wrote:

Prefix filter does not work. I can gist if needed, but it's pretty
simple to explain. Assume three documents with values in a certain
field of:

"blue"
"blue red"
"red blue"

I need to filter documents where the field starts with "blue" (first
and second documents). A preview filter of "blue" will match all
three. That's because (it seems) it looks at terms (individual
words).

You said you wanted to use this on a non-analyzed field.

in which case, a prefix query works:

https://gist.github.com/851150

clint


(zouxcs) #6

I have the same question now,how did you solve it?give me a hint.Thank you


(system) #7