1
votes

For our system, we have a solr scheme defined with the basic TrieDateField fieldType, which has precisionStep=6 as well as stored/indexed/docvalues all equal to true. We also have a custom query parser which will take a query like 'date > 2012-02-10T13:19:11Z' and turn it into a range query (in lucene syntax it would look something like date:{1328879951000 TO *], but under the hoods it's just calling the getRangeQuery method on a TrieDateField object).

When running the query date > 2012-02-10T13:19:11Z in solr, I will correctly get back documents with a date field of 2014-05-11T12:00:00Z. However, when matching using luwak, the above query matches against nothing. In fact, the only query that works is with strict equality. However, if i change the precisionStep in the scheme for tdate to be either 0 or a high number (above say 32), all range queries work as expected.

Is there a reason range queries are matching only with less indexed ranges (higher precisionStep)? Why is it different between solr and luwak, if they're using the same schema and same query parser?

1

1 Answers

1
votes

If anyone comes across this later (though this was probably a niche question considering no answers and I'm using a deprecated field type), I was indexing the the date without a specified precisionStep, while the query DID have a precisionStep.

When building the luwak document, I did:

InputDocument doc = InputDocument.builder("doc1")
    .addField("date", iso_date_string, customAnalyzer).build();

When I needed to do something akin to:

FieldType ft = new FieldType();
ft.setNumericType(FieldType.LegacyNumericType.LONG);
ft.setNumericPrecisionStep(6);
ft.setStored(false);
ft.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
LegacyLongFiled field = ("date", iso_date_as_long, ft);
builder.addField(field);

Where iso_date_as_long is the given iso_date_string converted to date with JodaTime, converted back to string with DateTools.dateToString, and then converted to a long again with DateTools.stringToTime.