我正在使用elasticsearch 6.0.1并在BulkRequest request = new BulkRequest();上 我收到以下错误。我已经在线检查过,大多数人说如果我在类路径中有不同版本的lucene jar,就会发生这种情况。
java.lang.NoSuchFieldError: LUCENE_6_0_0
at org.elasticsearch.Version.<clinit>(Version.java:44)
at org.elasticsearch.common.logging.DeprecationLogger.<clinit>(DeprecationLogger.java:159)
at org.elasticsearch.action.bulk.BulkRequest.<clinit>(BulkRequest.java:67)
at com.gci.geospatial_analysis.db.es.EsIndexClient.insert_layer_metadata_bulk(EsIndexClient.java:19)
at com.gci.geospatial_analysis.ElasticsearchTest.insert_documents_test1(ElasticsearchTest.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Run Code Online (Sandbox Code Playgroud)
下面是我的pom,我认为classpath中没有其他任何Lucene版本。
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.3</version>
</dependency>
<dependency> …Run Code Online (Sandbox Code Playgroud) maven elasticsearch elasticsearch-plugin elasticsearch-java-api elasticsearch-6
参考官方文档中提到的建立亲子关系的例子——https: //www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html
该链接提供了问答连接关系,其中问题是父类型,答案是子类型。
如果您需要在一个查询中搜索匹配某些文本的所有父母以及他们的孩子匹配某些特定于孩子的文本,您会怎么做?
假设他们在 json 文档中有键值对,如下所示,我们搜索与问题中的文本匹配的父项和与 answer-text 中的值匹配的子项。
Parent --> question --> "question-text" : "Geography: Where is Mt. Everest?"
Child --> answer --> "answer-text" : "Nepal?"
Run Code Online (Sandbox Code Playgroud)
我们不希望结果中只包含父项或子项,而是所有父项及其与查询匹配的关联子项。
我知道内部命中是一种选择,但无法弄清楚用法 - https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html
我希望问题很清楚,如果需要可以添加更多细节。
我还尝试了此处提到的父子内部命中示例:
例子:
POST test_index/_search
{
"query": {
"has_child": {
"type": "child",
"query": {
"match": {
"number": 2
}
},
"inner_hits": {}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这给了我所有父母的匹配孩子。如何向父级添加过滤器并仅查询同一查询中的特定父级(以及子级过滤器)?是否可以在同一查询中的特定字段上过滤父记录?
像这样的东西——
POST test_index/_search
{
"query": {
<match parents first on number:1 and then match the children below>
"has_child": {
"type": "child",
"query": { …Run Code Online (Sandbox Code Playgroud) 在这里学习一些elasticsearch,我对在脚本化字段定义中使用 min 和 max 函数感到有点困惑。第一的,
GET my_index/_search
{
"query" : {
"match_all": {}
},
"script_fields" : {
"test1" : {
"script" : {
"lang": "painless",
"source": "min(doc[\"this field\"],5)"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我得到的回报是
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"min(doc[\"end\"],5)",
"^---- HERE"
],
"script": "min(doc[\"end\"],5)",
"lang": "painless"
}
], ...
Run Code Online (Sandbox Code Playgroud)
我想也许我需要给它命名Long.min并返回
"reason": "runtime error",
"script_stack": [
"""Long.min(doc["end"],5)""",
" ^---- HERE"
],
Run Code Online (Sandbox Code Playgroud)
这看起来是进步,但为什么会出现问题呢doc?
它们似乎在无痛 API 参考中,我认为如果它们不可用,那就有点愚蠢了。我一直在寻找“无痛最小最大功能”的组合,但我得到的只是上面链接的内容和一堆不相关的东西。
我在这里做错了什么?
我正在做一个项目来索引elasticsearch(版本6)中的网站问题和答案以供搜索.
我首先考虑创建两个索引,如下所示,一个用于问题,一个用于答案.
问题映射:
{"mappings": {
"question": {
"properties": {
"title":{
"type":"text"
},
"question": {
"type": "text"
},
"questionId":{
"type":"keyword"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
答案映射:
{"mappings": {
"answer": {
"properties": {
"answer":{
"type":"text"
},
"answerId": {
"type": "keyword"
},
"questionId":{
"type":"keyword"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我已经使用multimatch查询以及term和top_hits聚合来搜索索引的Q&A(引用的问题).我使用此方法从搜索结果中删除重复项.由于同一问题的答案或问题本身可能会出现在结果中.我只想在结果中每个问题输入一个条目.我面临的问题是对结果进行分页.没有可能的方法在elasticsearch中分页聚合.它只能分页命中而不是聚合.
然后我想到将一个问题和答案保存在一个文档中,答案在Json数组中.这种方法的问题在于没有干净的方法来添加,删除,更新给定问题文档中的特定答案.我发现的唯一方法是使用groovy脚本(引用问题).在elasticsearch v6 AFAIK中已弃用.
有没有更好更干净的设计方法?谢谢.
我有一个包含多个字段的索引。我想根据除 one - user_comments之外的所有字段中是否存在搜索字符串来过滤掉。我正在做的查询搜索是
{
"from": offset,
"size": limit,
"_source": [
"document_title"
],
"query": {
"function_score": {
"query": {
"bool": {
"must":
{
"query_string": {
"query": "#{query}"
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
尽管查询字符串正在搜索所有字段,并在user_comments字段中为我提供具有匹配字符串的文档。但是,我想针对所有不包含user_comments字段的字段来查询它。白名单是一个非常大的列表,而且字段的名称是动态的,因此使用 fields 参数提及白名单字段列表是不可行的。
"query_string": {
"query": "#{query}",
"fields": [
"document_title",
"field2"
]
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以提出一个关于如何从搜索中排除字段的想法吗?
我试过下面的代码它工作正常,但它使用TransportClient删除所有文档。
DeleteByQueryRequestBuilder deleteByQueryRequestBuilder = DeleteByQueryAction.INSTANCE.newRequestBuilder(transportClient)
.filter(QueryBuilders.matchAllQuery())
.source(indexName);
BulkByScrollResponse response = deleteByQueryRequestBuilder
.filter(QueryBuilders.matchAllQuery()).get()
Run Code Online (Sandbox Code Playgroud)
我正在使用elasticsearch 6.1.4。使用RestHighLevelClient从索引中删除所有文档的方法是什么。
我正在使用 Docker 使用 Cassandra(3.11.1) 和 Elastic search(5.6.4) 运行 Janusgraph(0.3.1)。但是,现在我迁移到了最新版本,即(janusgraph:最新,Cassandra:3,弹性搜索:6.6.0)并且我正在运行多个图。这工作正常,但是,我无法使用旧数据。当我尝试挂载旧的 Cassandra 和 Elastic 搜索卷时,我在 Elastic 搜索方面遇到了一些问题。但是,当我使用最新版本和旧卷运行单个图形时,它运行良好。当我尝试使用多个图形时,Janusgraph 无法使用弹性搜索进行配置。
为此,我尝试使用陀螺仪格式(我已经从旧服务器导出)从图形中导入旧数据,而不是安装旧卷。但我也面临这个问题。
我尝试了两种方式,但在这两种方式中,我都面临一些问题。任何帮助将不胜感激
这是我的 docker-compose.yml 文件
version: "3"
services:
janusgraph:
image: janusgraph/janusgraph:latest
container_name: jce-janusgraph
environment:
JANUS_PROPS_TEMPLATE: cassandra-es
janusgraph.storage.backend: cql
janusgraph.storage.hostname: jce-cassandra
janusgraph.index.search.hostname: jce-elastic
volumes:
- /mnt/janusvol/janus/scripts:/opt/janusgraph/tmp/scripts
- /mnt/janusvol/janus/conf/gremlin-server.yaml:/opt/janusgraph/conf/gremlin-server/gremlin-server.yaml
- /mnt/janusvol/janus/conf/empty-sample.groovy:/opt/janusgraph/scripts/empty-sample.groovy
- /mnt/janusvol/janus/conf/janusgraph-cql-es-server-geniegraph.properties:/opt/janusgraph/conf/gremlin-server/janusgraph-cql-es-server-geniegraph.properties
- /mnt/janusvol/janus/conf/janusgraph-cql-es-server-aagraph.properties:/opt/janusgraph/conf/gremlin-server/janusgraph-cql-es-server-aagraph.properties
ports:
- "8182:8182"
networks:
- jce-network
healthcheck:
test: ["CMD", "bin/gremlin.sh", "-e", "scripts/remote-connect.groovy"]
interval: 10s
timeout: 30s
retries: 3
entrypoint:
- bin/gremlin-server.sh
- conf/gremlin-server/gremlin-server.yaml
links:
- cassandra
- elasticsearch
cassandra: …Run Code Online (Sandbox Code Playgroud) elasticsearch gremlin-server cassandra-3.0 janusgraph elasticsearch-6
我已经使用标准分析器对文档进行了索引
foo 1 bar
foo 2 bar
foo 3 bar
Run Code Online (Sandbox Code Playgroud)
等等..
当我进行像“ asdf foo 1 bar 2 ”这样的 mach 查询时,尽管查询字符串包含短语“foo 1 bar”,但foo 2 bar的得分高于foo 1 bar
如何构建查询以考虑词序?主要问题是查询字符串可能包含比文档更多的单词。
要求是创建一个自定义分析器,该分析器可以生成两个令牌,如以下方案所示。
例如
Input -> B.tech in
Output Tokens ->
- btechin
- b.tech in
Run Code Online (Sandbox Code Playgroud)
我可以删除非字母数字字符,但如何在输出令牌列表中也保留原始字符。以下是我创建的自定义分析器。
"alphanumericStringAnalyzer": {
"filter": [
"lowercase",
"minLength_filter"],
"char_filter": [
"specialCharactersFilter"
],
"type": "custom",
"tokenizer": "keyword"
}
"char_filter": {
"specialCharactersFilter": {
"pattern": "[^A-Za-z0-9]",
"type": "pattern_replace",
"replacement": ""
}
},
Run Code Online (Sandbox Code Playgroud)
该分析器正在为输入“ B.tech in”生成单个令牌“ btechin”,但我也希望令牌列表“ B.tech in”中也有原始令牌。
谢谢!
我对更新 search.max_buckets 有疑问,因为我收到一些警告,因为聚合创建了太多存储桶,所以我怀疑如果我更新这个值超过 10000,我会提高性能。现在我有一些想要改进的地方。
提前致谢。