2014-12-13 4 views
0

Я следую this guide и преобразовываю этот перколятивный код api java в scala, но когда я запускаю его в SBT, он вызывает следующее исключенияне удалось перколить: org.elasticsearch.index.percolator.PercolatorException: [myindex] не удалось выполнить синтаксический анализ запроса [myDesignatedQueryName]

[error] (run-main-0) org.elasticsearch.index.percolator.PercolatorException: [myindex] failed to parse query [myDesignatedQueryName] 
org.elasticsearch.index.percolator.PercolatorException: [myindex] failed to parse query [myDesignatedQueryName] 
    at org.elasticsearch.index.percolator.PercolatorQueriesRegistry.parsePercolatorDocument(PercolatorQueriesRegistry.java:194) 
    at org.elasticsearch.index.percolator.PercolatorQueriesRegistry$RealTimePercolatorOperationListener.preIndex(PercolatorQueriesRegistry.java:309) 
    at org.elasticsearch.index.indexing.ShardIndexingService.preIndex(ShardIndexingService.java:139) 
    at org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:420) 
    at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:193) 
    at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:511) 
    at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:419) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: org.elasticsearch.index.query.QueryParsingException: [myindex] Strict field resolution and no field mapping can be found for the field with name [content] 
    at org.elasticsearch.index.query.QueryParseContext.failIfFieldMappingNotFound(QueryParseContext.java:393) 
    at org.elasticsearch.index.query.QueryParseContext.smartFieldMappers(QueryParseContext.java:372) 
    at org.elasticsearch.index.query.TermQueryParser.parse(TermQueryParser.java:95) 
    at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:277) 
    at org.elasticsearch.index.query.IndexQueryParserService.parseInnerQuery(IndexQueryParserService.java:321) 
    at org.elasticsearch.index.percolator.PercolatorQueriesRegistry.parseQuery(PercolatorQueriesRegistry.java:207) 
    at org.elasticsearch.index.percolator.PercolatorQueriesRegistry.parsePercolatorDocument(PercolatorQueriesRegistry.java:191) 
    at org.elasticsearch.index.percolator.PercolatorQueriesRegistry$RealTimePercolatorOperationListener.preIndex(PercolatorQueriesRegistry.java:309) 
    at org.elasticsearch.index.indexing.ShardIndexingService.preIndex(ShardIndexingService.java:139) 
    at org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:420) 
    at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:193) 
    at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:511) 
    at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:419) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
    at java.lang.Thread.run(Thread.java:745) 
[trace] Stack trace suppressed: run last compile:run for the full output. 

вот мой код

object PercolateApiES extends App{ 
    val node =nodeBuilder().client(true).node() 
val client =node.client() 

    val qb=QueryBuilders.termQuery("content","amazing") 

val res=client.prepareIndex("myindex", ".percolator", "myDesignatedQueryName") 
    .setSource(jsonBuilder() 
     .startObject() 
      .field("query", qb) // Register the query 
     .endObject()) 
    .setRefresh(true) // Needed when the query shall be available immediately 
    .execute().actionGet(); 
val docBuilder = XContentFactory.jsonBuilder().startObject(); 
docBuilder.field("doc").startObject(); //This is needed to designate the document 
docBuilder.field("content", "This is amazing!"); 
docBuilder.endObject(); //End of the doc field 
docBuilder.endObject(); //End of the JSON root object 
//Percolate 
val response = client.preparePercolate() 
         .setIndices("myindex") 
         .setDocumentType("myDocumentType") 
         .setSource(docBuilder).execute().actionGet(); 
node.close 
} 

Когда я пишу эти команды с помощью завиток они работают хорошо

curl -XPUT 'localhost:9200/myindex1' -d '{ 
    "mappings": { 
    "mytype": { 
     "properties": { 
     "content": { 
      "type": "string" 
     } 
     } 
    } 
    } 
}' 

{"acknowledged":true} 

curl -XPUT 'localhost:9200/myindex1/.percolator/myDesignatedQueryName' -d '{ 
    "query" : { 
     "term" : { 
      "content" : "amazing" 
     } 
    } 
}' 


{"_index":"myindex1","_type":".percolator","_id":"myDesignatedQueryName","_version":1,"created":true} 

curl -XGET 'localhost:9200/myindex1/content/_percolate' -d '{ 
    "doc" : { 
     "content" : "This is amazing!" 
    } 
}' 

{"took":231,"_shards":{"total":5,"successful":5,"failed":0},"total":1,"matches":[{"_index":"myindex1","_id":"myDesignatedQueryName"}]} 

Я использую эластичный поиск-1.4.1 Пожалуйста, помогите мне, где я делаю ошибку, а также я хочу кипеть результаты ася не знают, как это сделать в коде

matches":[{"_index":"myindex1","_id":"myDesignatedQueryName"} 

Как я могу получить результат, пожалуйста, помогите мне и направить меня, спасибо

ответ

0

ES 1.4.0.Beta1 ввела нарушение, которое влияет на API-интерфейс перколятора. В принципе, мы должны установить index.query.parse.allow_unmapped_fields явно true. Для получения дополнительной информации см. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-dynamic-mapping.html#_unmapped_fields_in_queries.

Фактический разговор о добавлении этого изменения находится в их Github https://github.com/elasticsearch/elasticsearch/issues/6664.

Вот еще одна связанная с этим проблема: index.query.parse.allow_unmapped_fields setting does not seem to allow unmapped fields in alias filters