views:

358

answers:

3

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.

Thanks! Tim

A: 

Going through the solr tutorial is definitely worth your time: http://lucene.apache.org/solr/tutorial.html

My guess is that the "name" field is not indexed, so you can't search on it. You'd need to change your schema to make it indexed.

Also make sure that your XML actually lines up with the schema. So if you are adding a field named "name" in the xml, but the schema doesn't know about it, then Solr will just ignore that field (ie it won't be "stored" or "indexed").

Good luck

mlathe
Field is definitely indexed. Also, if it wasn't, I couldn't do some of the queries I listed, right? Something like name:tom wouldn't work, if I understand the docs.
Tim Ridgely
yea Mauricio has it right, that you need to specify the defaultSearchField in the solrconfig. Also if you are using DisMax (which would allow ?q=tom to cause a search in multiple fields at the same time), there is another setting called "qf"
mlathe
+4  A: 

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.

Mauricio Scheffer
Nice! This was exactly what I needed. I didn't see this option before, and now having a bunch of copyfields pointing to a large "text" field makes sense. Thanks so much!
Tim Ridgely
A: 

Well, despite of setting a default search field is quite usefull i don't understand why don't you just use the solr query syntax:

......./?q=name:tom

or

......./?q=:&fq=name:tom

Lici
ok, miss read the title :-(
Lici