Search code examples
solr

Querying Solr without specifying field names


I'm new to using Solr, and I must be missing something.

I didn't touch much in the example schema yet, and I imported some sample data. I also set up LocalSolr, and that seems to be working well.

My issue is just with querying Solr in general. I have a document where the name field is set to tom. I keep looking at the config files, and I just can't figure out where I'm going awry. A bunch of fields are indexed and stored, and I can see the values in the admin, but I can't get querying to work properly. I've tried various queries (http://server.com/solr/select/?q=value), and here are the results:

**Query:** ?q=tom
**Result:** No results

**Query:** q=\*:\*
**Result:** 10 docs returned

**Query:** ?q=*:tom
**Result:** No results

**Query:** ?q=name:tom
**Result:** 1 result (the doc with name : tom)

I want to get the first case (?q=tom) working. Any input on what might be going wrong, and how I can correct it, would be appreciated.


Solution

  • Set <defaultSearchField> to name in your schema.xml

    The <defaultSearchField> Is used by Solr when parsing queries to identify which field name should be searched in queries where an explicit field name has not been used.

    You might also want to check out (e)dismax instead.