Using Span First with fuzziness

Hello,

I am new to Elasticsearch and i need to use the term of the search to gain score if it is in the beginning of the document but i need to use fuzziness in that term too. I tried something like this but i couldnt because the span_first doesnt support fuzziness .

    POST /produto/default/_search
    {
      "_source": [
        "nome",
        "descricao",
        "categoria.nome"
      ],
      "query": {
        "bool": {
          "must": {
            "multi_match": {
              "query": "acucar",
              "tie_breaker": "1.0",
              "fields": [
                "nome",
                "descricao",
                "categoria.nome"
              ],
              "fuzziness": "auto"
            }
          },
          "should": [
            {
              "span_first": {
                "match": {
                  "span_term": {
                    "nome": "acucar"
                  }
                },
                "end": 1
              }
            },
            {
              "span_first": {
                "match": {
                  "span_term": {
                    "nome": "acucar"
                  }
                },
                "end": 2,
                "fuzziness": "auto"
              }
            }
      ]
    }
  }
}

Is it possible to do it in another way?

Thanks in advance and sorry for the bad english.

I was able to do it in the following way:

POST /produto/default/_search
{
  "_source": [
    "nome",
    "descricao",
    "categoria.nome"
  ],
  "query": {
    "bool": {
      "must": {
        "multi_match": {
          "query": "acucar",
          "tie_breaker": "1.0",
          "fields": [
            "nome",
            "descricao",
            "categoria.nome"
          ],
          "fuzziness": "auto"
        }
      },
      "should": [
        {
          "span_first": {
            "match": {
              "span_multi": {
                "match": {
                  "fuzzy": {
                      "nome": {"value": "acucar"}
                  }
                }
              }
            },
                  "end": 1
          }
        },
        {
          "span_first": {
            "match": {
              "span_multi": {
                "match": {
                  "fuzzy": {
                      "nome": {"value": "acucar"}
                  }
                }
              }
            },
                  "end": 2
          }
        }
      ]
    }
  }
}

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