What do you mean "doesn't work"? An empty string is
different than not being present. Thee UUID update
processor (I'm pretty sure) only adds a field if it
is _absent_. Specifying it as an empty string
fails that test so no value is added.

At that point, if this uuid field is also the <unkqueKey>,
then each doc that comes in with an empty field will replace
the others.

If it's _not_ the <unkqueKey>, the sorting will be confusing.
All the empty string fields are equal, so the tiebreaker is
the internal Lucene doc ID, which may change as merges
happen. You can specify secondary sort fields to make the
sort predictable (the <unkqueKey> field is popular for this).

Best,
Erick

On Thu, Apr 14, 2016 at 12:18 PM, Susmit Shukla <shukla.sus...@gmail.com> wrote:
> Hi,
>
> I have configured solr schema to generate unique id for a collection using
> UUIDUpdateProcessorFactory
>
> I am seeing a peculiar behavior - if the unique 'id' field is explicitly
> set as empty string in the SolrInputDocument, the document gets indexed
> with UUID update processor generating the id.
> However, sorting does not work if uuid was generated in this way. Also
> cursor functionality that depends on unique id sort also does not work.
> I guess the correct behavior would be to fail the indexing if user provides
> an empty string for a uuid field.
>
> The issues do not happen if I omit the id field from the SolrInputDocument .
>
> SolrInputDocument
>
> solrDoc.addField("id", "");
>
> ...
>
> I am using schema similar to below-
>
> <!--schema.xml-->
>
> <fieldType name="uuid" class="solr.UUIDField" indexed="true" />
>
> <field name="id" type="uuid" indexed="true" stored="true" required="true" />
>
> <uniqueKey>id</uniqueKey>
>
> <!--solrconfig.xml-->
> <updateRequestProcessorChain name="uuid">
>     <processor class="solr.UUIDUpdateProcessorFactory">
>       <str name="fieldName">id</str>
>     </processor>
>     <processor class="solr.RunUpdateProcessorFactory" />
> </updateRequestProcessorChain>
>
>
>  <requestHandler name="/update" class="solr.UpdateRequestHandler">
>        <lst name="defaults">
>          <str name="update.chain">uuid</str>
>        </lst>
> </requestHandler>
>
>
> Thanks,
> Susmit

Reply via email to