You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Phil Hagelberg <ph...@hagelb.org> on 2009/11/26 01:01:46 UTC

Date ranges for indexes constructed outside Solr

I'm working on an application that will build indexes directly using the
Lucene API, but will expose them to clients using Solr. I'm seeing
plenty of documentation on how to support date range fields in Solr,
but they all assume that you are inserting documents through Solr rather
than merging already-generated indexes.

Where can I find details about the Lucene-level field operations that
can be used to generate date fields that Solr will work with? In
particular date resolution settings are unclear.

On a similar note: how much of schema.xml is relevant in cases where
Solr is not performing insertions? Obviously defaultSearchField is as
well as the solrQueryParser defaultOperator attribute, but it seems like
most of the field declarations might not matter.

thanks,
Phil

Re: Date ranges for indexes constructed outside Solr

Posted by Chris Hostetter <ho...@fucit.org>.
: I'm working on an application that will build indexes directly using the
: Lucene API, but will expose them to clients using Solr. I'm seeing

I would suggest that you use SOlr in "embedded" mode to build your indexes 
-- that way you can insure schema compatibility of the index generated 
with the indexed search (and the embeded Solr code will take care of the 
indexed value incoding for you)

: Where can I find details about the Lucene-level field operations that
: can be used to generate date fields that Solr will work with? In
: particular date resolution settings are unclear.

Date's are all indexed with milisecond precision unless you explicitly 
round them in clinet code (in which case they are still indexed with 
milisecond precision, but you can only search on them at the precision you 
rounded to)

If you want to know exactly how Solr encodes a date value at index time, 
you have to look at the various methods of the FieldType in question (Solr 
actauly has three Date based field times -- two of which are legacy types 
included only for back compatibility)

: On a similar note: how much of schema.xml is relevant in cases where
: Solr is not performing insertions? Obviously defaultSearchField is as
: well as the solrQueryParser defaultOperator attribute, but it seems like
: most of the field declarations might not matter.

if a field isn't listed, Solr won't let you query for it or sort on it and 
it won't know what typing to apply when returning stored values.  if the 
field typing information isn't correct, then solr may not be able to 
properly search on a field (because the value may not be encoded ina way 
solr udnerstands) -- this particularly includes the query analyzer 
settings for text fields are important for solr to know what type of 
analysis to apply to the query string in order to search in a given text 
(ie: should it lowercase? was stemming applied at index time? were stop 
words removed?, etc...)

this is why things like embedded solr are recommended for people who have 
a specific need to index w/o using a solr server ... it is possible to use 
Solr to search an index that wasn't built using SOlr, but it requires you 
to be very careful about making sure the schema.xml you provide solr 
exactly matches what the index building code was doing.

-Hoss