I am using Spring Data Elasticsearch with a repository class. Here is My Object that I want to query through:
public class Person{
String firstName;
String lastName;
Location location;
}
public class Location{
String name;
}
@Query("{\"bool\" : {"
+ "\"should\" : [ "
+ "{"
+ "\"term\" : {"
+ "\"firstName\" : \"?0\""
+ "}"
+ "},"
+ "{"
+ "\"term\" : {"
+ "\"lastName\" : \"?0\""
+ "}"
+ "},"
+ "{"
+ "\"term\" : {"
+ "\"location.name\" : \"?0\""
+ "}"
+ "}"
+ "]"
+ "}}")
List<Person> findByFirstNameOrLastName(String term);
I can not search in location.name - how can I change the Query that this will work?
UPDATE Mapping
{
"properties" : {
"firstName": {
"type": "string",
"analyzer": "firstNameNGram"
},
"lastName": {
"type": "string",
"analyzer": "firstNameNGram"
},
"location": {
"type": "nested",
"properties": {
"name": {
"type": "string",
"analyzer": "firstNameNGram"
},
"company": {
"type": "nested",
"properties": {
"name": {
"type": "string",
"analyzer": "firstNameNGram"
}
}
}
}
}
}
}