0
Ich verwende Spring Data Elasticsearch mit einer Repository-Klasse. Hier ist mein Objekt, das ich will Abfrage durch:Spring Data Elasticsearch Repository: Abfrage für verschachteltes Objekt
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);
Ich kann nicht in location.name suchen - wie kann ich die Abfrage ändern, dass dies funktionieren wird?
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"
}
}
}
}
}
}
}
Aktualisiert mein Fragenabschnitt w ith added Mapping –
Großartig, das hat für mich funktioniert !! –