Match against stored wildcard string

(Fredrik Hörte) #1

I want to be able to match a given string against a field that contains a value where an asterix is a placeholder for any given value.

I have a string and I want to return all documents that does not contain the exact match for or the record * In the below example it should return Document 2. Is this possible?

Document 1

domains: [,, *] 

Document 2

domains: [,] 

Document 3

domains: [] 

(Christoph) #2

Hi Fredrik,

unfortunately I think it is not possible to use wildcards in field values and then match them against a concrete query, but I have some hints that might be useful towards a solution.

This blog post that explains how to use the path hierarchy tokenizer for domain names, so the parts of your domains will be stored in reverse order in the index. With this you might be able to use a match or prefix query in a must_not clause of a bool query to archieve what you are looking for.

I dont know about the exact use case you have, but maybe you can drop the wildcard in the subdomains and then do a negated search on the "" part using the reversed domain name? Not sure this completely solves your problem but maybe it helps.

(system) #3