0
我们使用下面的设置与ES:嵌套场弹性搜索不工作
#Settings for elastic search
fos_elastica:
clients:
default:
host: %elastic_server_host%
port: %elastic_server_port%
headers: { Authorization: 'Basic %elastic_server_credential%' }
indexes:
organizations:
settings:
index:
analysis:
analyzer:
classic_analyser:
type: custom
tokenizer: lowercase
filter : [my_snow]
simple_analyser:
type: custom
tokenizer: lowercase
email_analyser:
type: custom
tokenizer: uax_url_email
filter:
my_snow:
type : "snowball"
language : "English"
client: default
types:
packages:
mappings:
id:
type: integer
trackingCode:
type: string
index: not_analyzed
damaged:
type: boolean
urgent:
type: boolean
perishable:
type: boolean
checkedOut:
type: date
created:
type: date
confirmationType:
type: integer
forwardedTrackingCode :
type: string
index: not_analyzed
firstNote : { type: string, analyzer: classic_analyser }
secondNote : { type: string, analyzer: classic_analyser }
deleted:
type: date
recipientId:
type: nested
properties:
id:
type: integer
internalId: { type: string, analyzer: simple_analyser }
firstName: { type: string, analyzer: simple_analyser }
lastName: { type: string, analyzer: simple_analyser }
email: { type: string, analyzer: email_analyser }
mailbox: { type: string, analyzer: simple_analyser }
phoneNumber:
type: string
index: not_analyzed
mobileNumber:
type: string
index: not_analyzed
jointAccountHolder: { type: string, analyzer: simple_analyser }
deliveryMode: ~
deleted:
type: date
address:
type: nested
properties:
address:
type: nested
properties:
country:
type: string
index: not_analyzed
organisationName:
type: string
index: not_analyzed
administrativeArea:
type: string
index: not_analyzed
locality:
type: string
index: not_analyzed
postalCode:
type: string
index: not_analyzed
thoroughfare:
type: string
index: not_analyzed
premise:
type: string
index: not_analyzed
carrierId:
type: nested
properties:
id:
type: integer
slug:
type: string
index: not_analyzed
name:
type: string
index: not_analyzed
phone:
type: string
index: not_analyzed
otherName:
type: string
index: not_analyzed
webUrl:
type: string
index: not_analyzed
persistence:
driver: orm
model: MyCode\PackageBundle\Entity\Packages
finder: ~
provider: ~
listener: ~
repository: MyCode\PackageBundle\Entity\ElasticaPackagesRepository
recipients:
mappings:
id:
type: integer
internalId: { type: string, analyzer: simple_analyser }
firstName: { type: string, analyzer: simple_analyser }
lastName: { type: string, analyzer: simple_analyser }
email: { type: string, analyzer: email_analyser }
mailbox: { type: string, analyzer: simple_analyser }
phoneNumber:
type: string
index: not_analyzed
mobileNumber:
type: string
index: not_analyzed
jointAccountHolder: { type: string, analyzer: simple_analyser }
deliveryMode: ~
deleted:
type: date
address:
type: nested
properties:
address:
type: nested
properties:
country:
type: string
index: not_analyzed
organisationName:
type: string
index: not_analyzed
administrativeArea:
type: string
index: not_analyzed
locality:
type: string
index: not_analyzed
postalCode:
type: string
index: not_analyzed
thoroughfare:
type: string
index: not_analyzed
premise:
type: string
index: not_analyzed
persistence:
driver: orm
model: MyCode\RecipientBundle\Entity\Recipient
finder: ~
provider: ~
listener: ~
repository: MyCode\RecipientBundle\Entity\ElasticaRecipientRepository
总之,我们使用两种不同类型---包&收件人。另外,与包关联的收件人也存储在ES中。现在
,如果我们搜索,如:
{
"query": {
"query_string": {
"query": "[email protected]",
"fields": [
"packages.recipientId.email"
],
"default_operator": "OR"
}
},
"size": "50",
"from": "0",
"sort": {
"id": {
"order": "asc"
}
}
}
ES是不是尽管特定的收件人做存在返回任何记录。 但是,如果我们像这样搜索:
{
"query": {
"query_string": {
"query": "[email protected]",
"fields": [
"recipients.email"
],
"default_operator": "OR"
}
},
"size": "50",
"from": "0",
"sort": {
"id": {
"order": "asc"
}
}
}
ES正在返回记录。 我不明白为什么搜索在以上两种情况下表现不同。
您能否建议我们需要更改/更正以便搜索在两种情况下均可行?