Spring Data Elasticsearch containing query with spaces
I have an object named Port
with a field portName
. I wrote the following Spring ES data request method for a request containing
:
List<Port> ports = portRepository.findByPortNameContaining(searchText);
It works fine as long as searchText
it contains no spaces. If so, I get the following error:
"Cannot constructQuery '*\"sample port\"*'. Use expression or multiple clauses instead."
When I try to use Spring Data ES search
like:
List<Port> ports = Lists.newArrayList(portRepository.search(
queryStringQuery(searchText)
.field("portName")
));
If I have a port named Loui Kentucky
, I can get results when searchText
is a full word like Loui
or Kentucky
or Loui Kentucky
. The same happens with analyzeWildcard
:
List<Port> ports = Lists.newArrayList(portRepository.search(
boolQuery().should(queryStringQuery(searchText).analyzeWildcard(true).field("portName"))
));
I want to build a simple query containing query that can handle spaces as well. No blur. Search results should appear even if I search i K
because it Loui Kentucky
contains this substring.
No one has answered this question yet
Check out similar questions: