elastic / elasticsearch-mapper-attachments

Mapper Attachments Type plugin for Elasticsearch
https://www.elastic.co
Apache License 2.0
503 stars 94 forks source link

Having any attachment field in the index breaks lenient queries. #123

Closed ha107642 closed 9 years ago

ha107642 commented 9 years ago

How to reproduce:

  1. DELETE localhost:9200/platina
  2. PUT localhost:9200/platina
  3. PUT localhost:9200/platina/test/_mapping
{
    "test" : {
        "properties" : {
            "date" : {
              "type": "date",
              "format": "dateOptionalTime" 
          }
        }
    }
}
  1. POST localhost:9200/platina/test/_search
{
  "query": {
        "query_string":{
          "fields": [ "*" ],
          "query": "hej",
          "lenient": true
        }
  }
}

Zero results are returned, since no documents exist.

  1. PUT localhost:9200/platina/documents/_mapping
{
    "documents": {
        "properties": {
            "file": {
              "type": "attachment"
            }
        }
    }
}
  1. POST localhost:9200/platina/test/_search
{
  "query": {
        "query_string":{
          "fields": [ "*" ],
          "query": "hej",
          "lenient": true
        }
  }
}

Performing the search again yields:

[2015-04-13 12:08:57,498][DEBUG][action.search.type       ] [Halflife] [platina][0], node[IZn3WSqDRSWi0ANyz1Tvng], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@aadad5] lastShard [true]
org.elasticsearch.search.SearchParseException: [platina][0]: from[-1],size[-1]:
Parse Failure [Failed to parse source [{
  "query": {
        "query_string":{
          "fields": [ "*" ],
          "query": "hej",
          "lenient": true
        }
  }
}]]
        at org.elasticsearch.search.SearchService.parseSource(SearchService.java:681)
        at org.elasticsearch.search.SearchService.createContext(SearchService.java:537)
        at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:509)
        at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:264)
        at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:231)
        at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:228)
        at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:559)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Invalid format: "hej"
        at org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:754)
        at org.elasticsearch.index.analysis.NumericDateTokenizer.setValue(NumericDateTokenizer.java:39)
        at org.elasticsearch.index.analysis.NumericTokenizer.incrementToken(NumericTokenizer.java:80)
        at org.apache.lucene.analysis.CachingTokenFilter.fillCache(CachingTokenFilter.java:90)
        at org.apache.lucene.analysis.CachingTokenFilter.incrementToken(CachingTokenFilter.java:55)
        at org.apache.lucene.util.QueryBuilder.createFieldQuery(QueryBuilder.java:217)
        at org.apache.lucene.queryparser.classic.QueryParserBase.newFieldQuery(QueryParserBase.java:473)
        at org.apache.lucene.queryparser.classic.QueryParserBase.getFieldQuery(QueryParserBase.java:465)
        at org.apache.lucene.queryparser.classic.MapperQueryParser.getFieldQuerySingle(MapperQueryParser.java:273)
        at org.apache.lucene.queryparser.classic.MapperQueryParser.getFieldQuery(MapperQueryParser.java:174)
        at org.apache.lucene.queryparser.classic.QueryParserBase.handleBareTokenQuery(QueryParserBase.java:845)
        at org.apache.lucene.queryparser.classic.QueryParser.Term(QueryParser.java:360)
        at org.apache.lucene.queryparser.classic.QueryParser.Clause(QueryParser.java:259)
        at org.apache.lucene.queryparser.classic.QueryParser.Query(QueryParser.java:183)
        at org.apache.lucene.queryparser.classic.QueryParser.TopLevelQuery(QueryParser.java:172)
        at org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:123)
        at org.apache.lucene.queryparser.classic.MapperQueryParser.parse(MapperQueryParser.java:882)
        at org.elasticsearch.index.query.QueryStringQueryParser.parse(QueryStringQueryParser.java:223)
        at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:277)
        at org.elasticsearch.index.query.IndexQueryParserService.innerParse(IndexQueryParserService.java:382)
        at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:281)
        at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:276)
        at org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)
        at org.elasticsearch.search.SearchService.parseSource(SearchService.java:665)
        ... 9 more
[2015-04-13 12:08:57,601][DEBUG][action.search.type       ] [Halflife] All shards failed for phase: [query]

Note that there are no documents in the index, and the attachment field is not of the same type as the searched type.

Maybe I'm missing some leniency setting for this plugin. I'm not entirely sure how I can resolve this, so I hope you can shed some light on it! :)

ha107642 commented 9 years ago

Sorry, this is probably not related to this plugin, but rather one of the fields that the plugin creates.