Query string doesn't work correctly

.Query("*" + searchWord + "*") OMG this is scary.

Did you see: Wildcard Query | Elasticsearch Guide [5.2] | Elastic

Note that this query can be slow, as it needs to iterate over many terms. In order to prevent extremely slow wildcard queries, a wildcard term should not start with one of the wildcards * or ?.

BTW please try to format correctly your posts (indentation) so it's more readable. You can use markdown like:

```
CODE
```

It would be easier also to have a full REST script which reproduces a full example of your problem.
Have a look at this example.

Analyze API will help you a lot to understand what is actually index and what elasticsearch will use at query time to analyze what the user is searching for.

Then it will be easier to check what match or does not match.

I don't believe that a match query needs to have any wildcard character TBH. I don't believe either that you should pass the analyzer within the query as it has been defined in the mapping.

Whatever, if you can provide a script, that will be easier to help.

1 Like