Reputation: 6540
I am using Solr 3.5.0 with the example server under jetty-6.1-SNAPSHOT. I have started with the default schema.xml, removed the default <field>
definitions, and specified my own, including these:
<field name="content" type="text_general" indexed="false" stored="false" required="true" />**
<field name="title" type="text_general" indexed="false" stored="true" required="true" />
<field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>
I have indexed set to false for the content
field, because I am trying to use this field in a copyField definition later on in the schema. And I have stored set to false because I don't need to see this content
field in query results.
Later in the schema, I have these copyFields defined:
<copyField source="title" dest="text"/>
<copyField source="content" dest="text"/>
And here's a sample of my data:
<add>
<doc>
<field name="id">2-29-56</field>
<field name="title">This is a test</field>
<field name="content">This is some content</field>
</doc>
</add>
I run the example Solr server with this schema using:
C:\solr\example>java -jar start.jar
I then try to send this sample doc to my Solr server:
C:\solr\example\exampledocs>java -jar post.jar test.xml
This is what I get back:
SimplePostTool: version 1.4
SimplePostTool: POSTing files to http://localhost:8983/solr/update..
SimplePostTool: POSTing file test.xml
SimplePostTool: FATAL: Solr returned an error #400 [doc=2-29-56] missing required field: content
I tried many different things, but if I change the schema so that indexed="true" for the content
field definition, it works. Or if I put that back to false and set stored="true", then it also works. It always fails if indexed AND stored are set to false.
This would sort of make sense, if I weren't defining a copyField that uses the content field. The sample schema comments even state:
"for best index size and searching performance, set "index" to false for all general text fields, use copyField to copy them to the catchall "text" field, and use that for searching."
So what is the right way to do this, the most efficient way?
Upvotes: 1
Views: 12554
Reputation: 52769
Required Field must be marked as indexed or stored.
You can remove the required attribute for both the fields and have both the indexed and stored as false.
As the text field is only searchable, you can have the field type to be normal string without any analysis for the other fields.
Upvotes: 7