Solr Ausnahme: Dokument fehlt die obligatorische uniqueKey Feld: id
Bekomme ich die obige Fehlermeldung beim Versuch, eine Zeile einfügen...Mein schema ist nachfolgend dargestellt und im mit das gleiche id-Feld
Python code:
import solr
# create a connection to a solr server
s = solr.SolrConnection('http://127.0.0.1:8983/solr')
# add a document to the index
doc = dict(
id="1",
name='Lucene in Action',
author_name='ErikHatcher',
)
print doc
s.add(doc,commit=True)
# do a search
response = s.query('title:lucene')
for hit in response.results:
print hit['title']
Error:
ERROR - 2014-07-29 00:29:09.752; org.apache.solr.common.SolrException; org.apache.solr.common.SolrException: Document is missing mandatory uniqueKey field: id
at org.apache.solr.update.AddUpdateCommand.getIndexedId(AddUpdateCommand.java:92)
at org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:717)
at org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:557)
at org.apache.solr.update.processor.LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:100)
at org.apache.solr.handler.loader.XMLLoader.processUpdate(XMLLoader.java:247)
<!-- Table Field -->
<field name="name" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="slug" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="author_name" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="sku" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="price" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="Old_price" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="is_active" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="is_bestseller" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="is_featured" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="description" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="meta_keywords" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="meta_description" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="created_at" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="updated_at" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="image" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="thumbnail" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="image_caption" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="category" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="content" type="text_general" indexed="false" stored="true" multiValued="true"/>
<!-- catchall field, containing all other searchable text fields (implemented
via copyField further on in this schema -->
<field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>
<!-- catchall text field that indexes tokens both normally and in reverse for efficient
leading wildcard queries. -->
<field name="text_rev" type="text_general_rev" indexed="true" stored="false" multiValued="true"/>
<!-- non-tokenized version of manufacturer to make it easier to sort or group
results by manufacturer. copied from "manu" via copyField -->
<field name="manu_exact" type="string" indexed="true" stored="false"/>
<field name="payloads" type="payloads" indexed="true" stored="true"/>
<field name="_version_" type="long" indexed="true" stored="true"/>
<dynamicField name="*_i" type="int" indexed="true" stored="true"/>
<dynamicField name="*_is" type="int" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_s" type="string" indexed="true" stored="true" />
<dynamicField name="*_ss" type="string" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_l" type="long" indexed="true" stored="true"/>
<dynamicField name="*_ls" type="long" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_t" type="text_general" indexed="true" stored="true"/>
<dynamicField name="*_txt" type="text_general" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_en" type="text_en" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
<dynamicField name="*_bs" type="boolean" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_f" type="float" indexed="true" stored="true"/>
<dynamicField name="*_fs" type="float" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_d" type="double" indexed="true" stored="true"/>
<dynamicField name="*_ds" type="double" indexed="true" stored="true" multiValued="true"/>
<!-- Type used to index the lat and lon components for the "location" FieldType -->
<dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false" />
<dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
<dynamicField name="*_dts" type="date" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_p" type="location" indexed="true" stored="true"/>
<!-- some trie-coded dynamic fields for faster range queries -->
<dynamicField name="*_ti" type="tint" indexed="true" stored="true"/>
<dynamicField name="*_tl" type="tlong" indexed="true" stored="true"/>
<dynamicField name="*_tf" type="tfloat" indexed="true" stored="true"/>
<dynamicField name="*_td" type="tdouble" indexed="true" stored="true"/>
<dynamicField name="*_tdt" type="tdate" indexed="true" stored="true"/>
<dynamicField name="*_pi" type="pint" indexed="true" stored="true"/>
<dynamicField name="*_c" type="currency" indexed="true" stored="true"/>
<dynamicField name="ignored_*" type="ignored" multiValued="true"/>
id
Es scheint nicht, Sie haben eine tatsächliche Feld namens
id
?InformationsquelleAutor user1050619 | 2014-07-29
Du musst angemeldet sein, um einen Kommentar abzugeben.
Es ist eine unglückliche Fehler in der solrpy Dokumentation. Die Dokumentation sagt, dass Sie übergeben add() ein dict-aber das ist falsch und die Quelle Ihrer Probleme.
Vom source code (core.py):
Können Sie sehen, dass der richtige Ansatz ist, um es zu übergeben Schlüsselwort=Wert Parameter in einer durch Kommas getrennten Liste, nicht eine dict. Wenn Sie diese Einstellung ich glaube, es wird funktionieren.
InformationsquelleAutor John Petrone
Bitte fügen Sie
<field name="id" XXXXXXXX />
in Ihrem schema.xml Datei.Nachdem Sie die änderungen, starten Sie den SOLR-Instanz oder, wenn Sie mit SOLR4.0 +, dann Sie können ausführen, die RELOAD Befehl, um die änderungen in Ihrem SOLR.
http://technical-fundas.blogspot.in/2014/07/solr-reload-solrconfigxml-and-schemaxml.html
HTH,
Jayesh Bhoyar
Sind Sie in der Lage, das problem zu lösen. Wenn ja, Was war das problem und wie hast du das Problem beheben...
Ja..ich habe die folgende änderung ...en.Beurteilung(**doc), s.commit() und es funktionierte
InformationsquelleAutor Jayesh Bhoyar