Hello guys, I'm new to the Elasticsearch world and I'm sorry if my doubt is very basic.
I need to create an index on there will be a type that will store a product catalog. In this there will be several fields but what I need to use for research is only one DESCRIPTION field.
Hello, thanks for the quick response.
I had already tried with the link instruction that you passed. However I was not successful. For example:
I have a product that the description is: "ARMARIO P/FERRAMENTA AM-2 / MARCON".
If I use the query as written below, it returns results: { "query": { "wildcard": { "descricao": { "value": "arma*" } } } }
However, with the other methods below, nothing returns { "query": { "wildcard": { "descricao": { "value": "arma*ferra*" } } } } { "query": { "wildcard": { "descricao": { "value": "ARMA* FERRA*" } } } } { "query": { "wildcard": { "descricao": { "value": "arma* *ferra*" } } } } { "query": { "wildcard": { "descricao": { "value": "ARMA* FERRAMENTA*" } } } }
If I use 2 terms or more, it does not return results.
Using wildcard I got a result very close to what I need. But now I have another problem.
For example, in my SQL database, if I send the following query
(SELECT * FROM produtos WHERE descricao LIKE 'PF%SX%1/2%') I get the following result: PF SX D 3/16X1/2 RI BSW-24 G2 PO PF SX D 3/16X 1.1/2 RI BSW-24 G2 PO PF SX D 3/16X 2.1/2 RI BSW-24 G2 PO PF SX F 1/4X 1/2 RI UNC-20 G2 PO PF SX F 1/4X 1.1/2 RI UNC-20 G2 PO PF SX F 1/4X 2.1/2 RI UNC-20 G2 PO PF SX F 1/4X 4.1/2 RI UNC-20 G2 PO PF SX F 1/4X 5.1/2 RI UNC-20 G2 PO PF SX G 5/16X 1/2 RI UNC-18 G2 PO
In elastic, if I search the way below, no results will return. { "query": { "bool": { "must": [ {"wildcard": {"descricao": "pf"}}, {"wildcard": {"descricao": "sx*"}}, {"wildcard": {"descricao": "1/2*"}} ] } } }
I believe the problem is the term 1/2. Because if I remove the condition {"wildcard": {"description": "1/2 *"} returns results.
You will need to change the mapping of the field to not be analyzed, otherwise the slashes will not be indexed.
you can check these 2 posts on how to use slashes in filters:
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.