Typically the uniqueKey field is a "string" field type (your schema uses "text_general"), although I don't think it is supposed to be a requirement. Still, it is one thing that stands out.

Actually, you may be running into some variation of SOLR-1401:

https://issues.apache.org/jira/browse/SOLR-1401

In other words, stick with "string" and stay away from a tokenized (text) key.

You could also get duplicates by merging cores or if your "add" has allowDups = "true" or overwrite="false".

-- Jack Krupansky

-----Original Message----- From: Parmeley, Michael
Sent: Friday, May 18, 2012 5:50 PM
To: solr-user@lucene.apache.org
Subject: Duplicate documents being added even with unique key

I have a uniquekey set in my schema; however, I am still getting duplicated documents added. Can anyone provide any insight into why this may be happening?

This is in my schema.xml:

<!-- Field to use to determine and enforce document uniqueness.
Unless this field is marked with required="false", it will be a required field
  -->
<uniqueKey>uniquekey</uniqueKey>

<field name="uniquekey" type="text_general" indexed="true" stored="true" required="true" />

On startup I get this message in catalina.out:

INFO: unique key field: uniquekey

However, you can see I get multiple documents:

<result name="response" numFound="7" start="0">
<doc>
<str name="abbreviation">PSR3</str>
<int name="clientid">1</int>
<str name="entitytype">Skill</str>
<int name="id">510</int>
<str name="name">Body and Soul</str>
<int name="projectid">1</int>
<int name="skillnumber">281</int>
<str name="uniquekey">Skill510</str>
</doc>
<doc>
<str name="abbreviation">PSR3</str>
<int name="clientid">1</int>
<str name="entitytype">Skill</str>
<int name="id">510</int>
<str name="name">Body and Soul</str>
<int name="projectid">1</int>
<int name="skillnumber">281</int>
<str name="uniquekey">Skill510</str>
</doc>
<doc>
<str name="abbreviation">PSR3</str>
<int name="clientid">1</int>
<str name="entitytype">Skill</str>
<int name="id">510</int>
<str name="name">Body and Soul</str>
<int name="projectid">1</int>
<int name="skillnumber">281</int>
<str name="uniquekey">Skill510</str>
</doc>
<doc>
<str name="abbreviation">PSR3</str>
<int name="clientid">1</int>
<str name="entitytype">Skill</str>
<int name="id">510</int>
<str name="name">Body and Soul</str>
<int name="projectid">1</int>
<int name="skillnumber">281</int>
<str name="uniquekey">Skill510</str>
</doc>
<doc>
<str name="abbreviation">PSR3</str>
<int name="clientid">1</int>
<str name="entitytype">Skill</str>
<int name="id">510</int>
<str name="name">Body and Soul</str>
<int name="projectid">1</int>
<int name="skillnumber">281</int>
<str name="uniquekey">Skill510</str>
</doc>
<doc>
<str name="abbreviation">PSR3</str>
<int name="clientid">1</int>
<str name="entitytype">Skill</str>
<int name="id">510</int>
<str name="name">Body and Soul</str>
<int name="projectid">1</int>
<int name="skillnumber">281</int>
<str name="uniquekey">Skill510</str>
</doc>
<doc>
<str name="abbreviation">PSR3</str>
<int name="clientid">1</int>
<str name="entitytype">Skill</str>
<int name="id">510</int>
<str name="name">Body and Soul</str>
<int name="projectid">1</int>
<int name="skillnumber">281</int>
<str name="uniquekey">Skill510</str>
</doc>
</result>

Reply via email to