24
votes

I've got a Solr instance running on my Ubuntu machine using the default Jetty server that the Solr download comes with. Whenever I start Solr using

java -jar start.jar

The server starts fine but there is always an exception thrown:

INFO: SolrDispatchFilter.init() done
Apr 12, 2012 2:01:56 PM org.apache.solr.common.SolrException log
SEVERE: org.apache.solr.common.SolrException: undefined field text

As I said though, the server will still start and I can see the Solr admin interface. I defined my schema as follows.

<fields>
    <field name="id" type="string" indexed="true" stored="true" />
    <field name="phraseID" type="int" indexed="true" stored="true" />
    <field name="translation" type="string" indexed="true" stored="true" />
</fields>
<uniqueKey>id</uniqueKey>

I was also able to perform a JSON update - I submitted a sample array of data that was accepted. Up to this point everything is fine.

When I attempt to run a query:

http://localhost:8983/solr/select/?q=*:*&version=2.2&start=0&rows=10&indent=on

It correctly returns all the data that I submitted in my sample earlier.

However, the moment I try to query using text, I receive an HTTP ERROR 404.

http://localhost:8983/solr/select/?q=fruit&version=2.2&start=0&rows=10&indent=on

--- returns ---

HTTP ERROR 400

Problem accessing /solr/select/. Reason:

    undefined field text
Powered by Jetty://
5

5 Answers

49
votes

I had the same problem. In case there is no <defaultSearchField> in the solrconfig.xml file, look for the /select handler.

Within that you would find something like this

<str name="df">text</str>

That is the culprit. df means the default field and it, by default, and agreeably, quite stupidly, is set to a field called text which many might not have.

Remove it and replace it with whatever is to be your default search field.

38
votes

Default solr configuration has defined some request handlers with defaults that match the default schema included in the solr tarball.

Check the request handlers defined in solrconfig and you might find that <str name="qf"> and other configuration values include some fields you haven't defined in the schema.

Also, check your schema.xml, that the default search field isn't set to text like this: <defaultSearchField>text</defaultSearchField>

0
votes

I have the same problem which appears either on a 404 answer sometimes as described above or as an exception in the jetty stack trace:

SEVERE: org.apache.solr.common.SolrException: undefined field text

   at org.apache.solr.schema.IndexSchema.getDynamicFieldType(IndexSchema.java:1330)
   at org.apache.solr.schema.IndexSchema.getFieldType(IndexSchema.java:1282)
   at org.apache.solr.search.SolrQueryParser.getWildcardQuery(SolrQueryParser.java:234)
   at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1414)

I checked the defaultSearchField which is set to "content" (which seems ok for me)

Edit: I have in my schema.xml the following definition for type text (see no problem in it)

<fieldType name="text" class="solr.TextField"
    positionIncrementGap="100">
    <analyzer>
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.StopFilterFactory"
            ignoreCase="true" words="stopwords.txt"/>
        <filter class="solr.WordDelimiterFilterFactory"
            generateWordParts="1" generateNumberParts="1"
            catenateWords="1" catenateNumbers="1" catenateAll="0"
            splitOnCaseChange="1"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.EnglishPorterFilterFactory"
            protected="protwords.txt"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
    </analyzer>
</fieldType>
0
votes

The text field is composed of copies of another fields, as specified in the default schema.xml (when inserting a new document).

So, when we have the df "text" in the solrconfig.xml, and we make a search without specifying the field on the solr admin page such as: video. It will be looked up in the text field (which is composed of copies of another fields).

0
votes

This may not always be the case, but when I got a similar issue, it turned out that restarting the Solr server using restart command didn't suffice. Explicitly stopping the server with the stop command and then starting it using the start command actually did the trick. I did not require to edit any file.

P.S. My issue was with only /clustering not being accessible for my Solr core.