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 Oleksandr Yermolenko <aa...@sumix.com> on 2015/11/03 15:24:08 UTC

how to change uniqueKey?

Hello, All,

I can't find the way to change uniqueKey in "managed-schema" environment!!!

my steps:
1. Solr 5.3.1

/opt/solr/bin/solr start
/opt/solr/bin/solr create -c my_mail

2. added a few fields:
curl -X POST -H 'Content-type:application/json' --data-binary '{
   "add-field":{"name":"sentDate", "type":"date", "indexed":true, 
"stored":true },
   "add-field":{"name":"subject", "type":"text_general", "indexed":true, 
"stored":true },
...
   "add-field":{"name":"flags", "type":"string", "indexed":true, 
"stored":true, "omitNorms":true, "multiValued":true },
   "add-field":{"name":"messageId", "type":"string", "indexed":true, 
"stored":true, "required":true, "multiValued":"false" },
   "add-field":{"name":"attachmentNames", "type":"string", 
"indexed":true, "stored":true, "omitNorms":true, "multiValued":true }
}' http://localhost:8983/solr/my_mail/schema

3. created according to the docs mail-data-config.xml:
<dataConfig>
   <document>
       <!--
         Note - In order to index attachments, set 
processAttachement="true" and drop
         Tika and its dependencies to lib directory
        -->
       <entity processor="MailEntityProcessor"
             user="XXXXXXXX"
             password="XXXXXXXXX"
             host="XXXXXXXXX"
             protocol="imaps"
             fetchMailsSince="2014-06-30 00:00:00"
             batchSize="20"
             folders="INBOX"
             processAttachement="false"
             name="mail_entity"/>
   </document>
</dataConfig>

4. put libs paths and requestHandler to solrconfig.xml
...
   <lib dir="/opt/solr/contrib/dataimporthandler/lib/" regex=".*\.jar" />
   <lib dir="/opt/solr/dist/" regex="solr-dataimporthandler-.*\.jar" />
   <lib dir="/opt/solr/contrib/dataimporthandler-extras/lib/" 
regex=".*\.jar" />
...
     <requestHandler name="/dataimport" class="solr.DataImportHandler">
       <lst name="defaults">
         <str name="config">mail-data-config.xml</str>
       </lst>
     </requestHandler>

5. try to dataimport my mailbox
and ... org.apache.solr.common.SolrException: Document is missing 
mandatory uniqueKey field: id

6. look at the examples in example/example-DIH/solr/mail/conf
...
  <uniqueKey>messageId</uniqueKey>
...

7. The first and the last question: the correct way changing uniqueKey 
in schemaless environment? what I missed?

Thanks a lot for everyone for reading and helping.

Oleksandr Yermolenko
network/systems engineer


Re: how to change uniqueKey?

Posted by Steve Rowe <sa...@gmail.com>.
Hi Oleksandr,

> On Nov 3, 2015, at 9:24 AM, Oleksandr Yermolenko <aa...@sumix.com> wrote:
> 
> Hello, All,
> 
> I can't find the way to change uniqueKey in "managed-schema" environment!!!

[…]

> 7. The first and the last question: the correct way changing uniqueKey in schemaless environment? what I missed?

There is an open issue to provide this capability: https://issues.apache.org/jira/browse/SOLR-7242 but no work done on it yet.

Re: how to change uniqueKey?

Posted by Mikhail Khludnev <mk...@griddynamics.com>.
Hello Oleksandr,

It seems there is no way ManagedIndexSchema doesn't even refer to
IndexSchema.uniqueKeyField.
You may only choose the proper (with uniqueKeyField) config set when
creating collection.

On Tue, Nov 3, 2015 at 5:24 PM, Oleksandr Yermolenko <aa...@sumix.com> wrote:

> Hello, All,
>
> I can't find the way to change uniqueKey in "managed-schema" environment!!!
>
> my steps:
> 1. Solr 5.3.1
>
> /opt/solr/bin/solr start
> /opt/solr/bin/solr create -c my_mail
>
> 2. added a few fields:
> curl -X POST -H 'Content-type:application/json' --data-binary '{
>   "add-field":{"name":"sentDate", "type":"date", "indexed":true,
> "stored":true },
>   "add-field":{"name":"subject", "type":"text_general", "indexed":true,
> "stored":true },
> ...
>   "add-field":{"name":"flags", "type":"string", "indexed":true,
> "stored":true, "omitNorms":true, "multiValued":true },
>   "add-field":{"name":"messageId", "type":"string", "indexed":true,
> "stored":true, "required":true, "multiValued":"false" },
>   "add-field":{"name":"attachmentNames", "type":"string", "indexed":true,
> "stored":true, "omitNorms":true, "multiValued":true }
> }' http://localhost:8983/solr/my_mail/schema
>
> 3. created according to the docs mail-data-config.xml:
> <dataConfig>
>   <document>
>       <!--
>         Note - In order to index attachments, set
> processAttachement="true" and drop
>         Tika and its dependencies to lib directory
>        -->
>       <entity processor="MailEntityProcessor"
>             user="XXXXXXXX"
>             password="XXXXXXXXX"
>             host="XXXXXXXXX"
>             protocol="imaps"
>             fetchMailsSince="2014-06-30 00:00:00"
>             batchSize="20"
>             folders="INBOX"
>             processAttachement="false"
>             name="mail_entity"/>
>   </document>
> </dataConfig>
>
> 4. put libs paths and requestHandler to solrconfig.xml
> ...
>   <lib dir="/opt/solr/contrib/dataimporthandler/lib/" regex=".*\.jar" />
>   <lib dir="/opt/solr/dist/" regex="solr-dataimporthandler-.*\.jar" />
>   <lib dir="/opt/solr/contrib/dataimporthandler-extras/lib/"
> regex=".*\.jar" />
> ...
>     <requestHandler name="/dataimport" class="solr.DataImportHandler">
>       <lst name="defaults">
>         <str name="config">mail-data-config.xml</str>
>       </lst>
>     </requestHandler>
>
> 5. try to dataimport my mailbox
> and ... org.apache.solr.common.SolrException: Document is missing
> mandatory uniqueKey field: id
>
> 6. look at the examples in example/example-DIH/solr/mail/conf
> ...
>  <uniqueKey>messageId</uniqueKey>
> ...
>
> 7. The first and the last question: the correct way changing uniqueKey in
> schemaless environment? what I missed?
>
> Thanks a lot for everyone for reading and helping.
>
> Oleksandr Yermolenko
> network/systems engineer
>
>


-- 
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<mk...@griddynamics.com>