我正在使用elasticsearch7和neo4j,并使用graphaware插件将neo4j复制到elasticsearch。到目前为止,一切都很好。另外,我还在使用用于Elasticsearch的模板来定义特定的映射,例如令牌生成器和分析器,以在Elasticsearch上启用自动完成搜索。 模板如下所示:
`PUT _template/template_neo4j
{
"index_patterns": ["neo4j*"],
"settings":
{
"number_of_shards": 1,
"analysis":
{
"filter":
{
"nGram_filter":
{
"type": "nGram",
"min_gram": 2,
"max_gram": 3,
"token_chars":
[
"letter",
"digit",
"punctuation",
"symbol"
]
}
},
"analyzer":
{
"nGram_analyzer":
{
"type": "custom",
"tokenizer": "whitespace",
"filter":
[
"lowercase",
"asciifolding",
"nGram_filter"
]
},
"whitespace_analyzer":
{
"type": "custom",
"tokenizer": "whitespace",
"filter":
[
"lowercase",
"asciifolding"
]
}
}
}
},
"mappings":
{
"dynamic_templates":
[
{
"string_fields":
{
"match":"*",
"match_mapping_type":"string",
"mapping":
{
"type":"text",
"analyzer":"nGram_analyzer"
}
}
}
],
"dynamic":true
}
}`
我正在使用动态模板来启用给定nGram_analyzer的所有字符串类型项。 此外,我正在使用以下 mapping.json :
{
"defaults": {
"key_property": "uuid",
"nodes_index": "neo4j-index-node",
"relationships_index": "neo4j-index-relationship",
"include_remaining_properties": false,
"exclude_empty_properties": true
},
"node_mappings": [
{
"condition": "hasLabel('GlobalBusiness')",
"type": "globalbsuiness",
"properties": {
"parentBusiness": "getProperty('BusinessName')",
"subGlobalFirm": "query('MATCH (n) WHERE id(n) = {id} MATCH (n:GlobalBusiness)-[:HAS_SUB_GLOBAL_FIRM]->(f:GlobalBusiness) RETURN collect(f.BusinessName) AS value')"
}
}
],
"relationship_mappings": [
{
"condition": "isType('HAS_SUB_GLOBAL_FIRM')",
"type": "globalFirm"
}
]
}`
当尝试启动neo4j数据库/索引图形时,发生以下错误:
`[2019-05-15T11:08:58,663][DEBUG][o.e.a.a.i.m.p.TransportPutMappingAction] [DE-20HEPF0XGV48] failed to put mappings on indices [[[neo4j-index-node/AAyW79tDTTebihkDl79kag]]], type [globalbsuiness]
java.lang.IllegalArgumentException: Rejecting mapping update to [neo4j-index-node] as the final mapping would have more than 1 type: [_doc, globalbsuiness]
at org.elasticsearch.index.mapper.MapperService.internalMerge(MapperService.java:449) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.index.mapper.MapperService.internalMerge(MapperService.java:398) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:331) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.applyRequest(MetaDataMappingService.java:315) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.execute(MetaDataMappingService.java:238) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:687) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:310) ~[elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cluster.service.MasterService.runTasks(MasterService.java:210) [elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cluster.service.MasterService$Batcher.run(MasterService.java:142) [elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:150) [elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:188) [elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:681) [elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:252) [elasticsearch-7.0.0.jar:7.0.0]
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:215) [elasticsearch-7.0.0.jar:7.0.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:835) [?:?]`
我猜发生了问题,因为default-index-template向所有术语 _doc 添加了自己的类型。当开始索引编制时,elasticsearch会获得另一个类型 globalbusiness ,它来自mapping.json。由于有两种类型,因此弹性搜索会拒绝来自mapping.json的映射。
我的问题是: 1.有人知道我该如何解决这个问题 2.是否可以在mapping.json中为anaylzer,tokenizer ..定义默认映射或引用模板。
PS:IAM使用以下插件:
graphaware-neo4j-to-elasticsearch-3.5.4.53.11.jar graphaware-server-community-all-3.5.4.53.jar graphaware-uuid-3.5.4.53.17.jar
使用elasticsearch 7和neo4j 3.5.2
neo4j中针对graphaware的设置为:
dbms.unmanaged_extension_classes=com.graphaware.server=/graphaware
com.graphaware.runtime.enabled=true
com.graphaware.module.UIDM.1=com.graphaware.module.uuid.UuidBootstrapper
com.graphaware.module.UIDM.uuidIndex=uuidIndex
com.graphaware.module.UIDM.uuidProperty=uuid
com.graphaware.module.UIDM.relationship=true
com.graphaware.module.UIDM.initializeUntil=0
com.graphaware.module.UIDM.node=hasLabel('GlobalBusiness')
com.graphaware.module.ES.2=com.graphaware.module.es.ElasticSearchModuleBootstrapper
com.graphaware.module.ES.uri=localhost
com.graphaware.module.ES.port=9200
com.graphaware.module.ES.protocol=http
com.graphaware.module.ES.keyProperty=uuid
com.graphaware.module.ES.retryOnError=false
com.graphaware.module.ES.queueSize=10000
com.graphaware.module.ES.reindexBatchSize=2000
com.graphaware.module.ES.node=hasLabel('GlobalBusiness')
com.graphaware.module.ES.relationship=(true)
com.graphaware.module.ES.bulk=true
com.graphaware.module.ES.initializeUntil=2222222222222
com.graphaware.module.ES.mapping=com.graphaware.module.es.mapping.JsonFileMapping
com.graphaware.module.ES.file=mapping.json
谢谢。
问候 尤恩斯
有人知道如何解决此问题