Reputation: 515
I am new in Solr. I have tried DataImport using a Oracle Database. The data gets successfully imported. When I try to search with query:
qt=standard q=*
I get good results. But when I do a specific search, the results are empty showing no documents. The logger is empty and there are NO errors displayed.
Upvotes: 0
Views: 702
Reputation: 83
TLDR Version: Define your fields as type="text"
to start off. If you have a field called "product", add <field name="product" type="text" indexed="true" stored="true" />
to the default schema.xml
inside the <fields>
tag and you should be done. To search using the select
request-handler, use q=<field_name>:<text_to_look_for>
or q=*:*
to show all documents.
There are a few mistakes you're making here. I'll be explaining using the 'select' request handler.
The format for a query is ?q=<field_name>:<text_to_look_for>
. So if you want to return all the values matching all the fields, you'd say q=*:*
And if you were to look for the word "iPod" in the field "product" your query would be q=product:iPod
Another thing to keep in mind is that if in schema.xml
, say if you specify the field product
as type="string"
which maps to class="solr.StrField"
, the query (<text_to_look_for>
) should precisely match the value in the index, since Solr doesn't tokenize the StrField by default, i.e., ipod
will not return results if your index holds it as iPod
. If you need it to return it still, you could use the type="text"
in schema.xml
(the fieldType definition is present already in the default schema.xml.) The "text" fieldType has several analyzers(one analyzer ignores case) and tokenizers(tokenizer splits up the words in the field and indexes them so that if you search for a particular word, say "ipod", it would match the value "iPod 16GB White").
Regarding your own answer, the <str name="df">text</str>
specifies the default field to search in, i.e, if you just said q=iPod
, it would look in this field. The objective of this field called text is to hold all the other fields in the document, so that you could just search in this field and know that some or the other field in this document would match your query, thereby you wouldn't need to search in a specific field if you don't know what field you're expecting the value to be in.
Upvotes: 1
Reputation: 515
Ok! I got it.
I observed that when I am using some pre-defined fields of schema.xml, the search on those fields are working fine. But when I defined some fields of my own, the result was still NOTHING.
Then I looked into "solr-config.xml's" "/select" request handler. There is a line
<str name="df">text</str>
which says that "txt" is the only field which is searchable. But then how does it searches the other fields?
Answer lies in "schema.xml's"
"<copyField>"
tag. The fields present by default are copied into "text" which makes them searchable. Hence if you want your defined field as searchable, just define your field and add it in copyField tag. ;)
Upvotes: 1