Store text with hiphens and dot


(Shashank Raghuveer) #1

I am trying to come up with a query for elastic search to search for strings with hiphen and dots example : "PN-8100.0500-070, PN-8100.0500, PN-8100.0500-180". The search should be able to match exact strings like "PN-8100.0500-070" or "PN-8100.0500" in the above example. Note : The example string is a single field in elasticsearch index.

I tried using the query string with minimum match set to 100%, but it doesn't quite do complete match on the string (it returns entries with PN-8100.0500 as well).

Would it help if I store the comma separated string as string array and search using keyword analyzer.?

Any suggestions would be greatly appreciated. Thanks


(Christoph) #2

If there is only a single "PN-123814.2314-323" thingy per field in the input document, its enough to map them to the "keyword" type or use the ".raw" multifield if you use the default mapping. If there are several of these Ids in a field of the input document, you need to find a tokenizer that splits them correctly without removing the dots/hyphens in the ids. For example, if the come as "PN-8100.0500-070, PN-8100.0500, PN-8100.0500-180" like you mentioned, you might be able to use the Pattern Tokenizer, the Simple Pattern Tokenizer or the Simple Pattern Split Tokenizer and break on comma and whitespace.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.