When I enter search url
http://localhost:8983/solr/select?qt=standard&rows=10&q=*:*
I get a response with 10 documents.
But when I want to test specific query, then nothing comes up. For example:
http://localhost:8983/solr/select?qt=standard&rows=10&q=white
Why is that happening? I clearly see in results, that there is document with word "White" in it. So Why solr dont return that document as result.?
q=*:* searches for all content on all the documents, hence you get back the results.
q=white will search for white on the default search field, which is usually text if you have not modified the schema.xml.
<defaultSearchField>text</defaultSearchField>
You can change the default field to be the field you want to search on.
OR use specific field to search on the specific field e.g. title q=title:white
If you want to search on multiple field, you can combine the fields into one field by using copyfields or use dismax request handler.
Related
I'm working with solr to store web crawling search results to be used in a search engine. The structure of my documents in solr is the following:
{
word: The word received after tokenizing the body obtained from the html.
url: The url where this word was found.
frequency: The no. of times the word was found in the url.
}
When I go the Solr dashboard on my system, which is http://localhost:8983/solr/#/CrawlerSearchResults/query I'm able to find a word say "Amazon" with the query "word: Amazon" but on directly searching for Amazon I get no results. Could you please help me out with this issue ?
Image links below.
First case
Second case (No results)
Thanks,
Nilesh.
In your second example, the value is searched against the default search field (since you haven't provided a field name). This is by default a field named _text_.
To support just typing a query into the q parameter without field names, you can either set the default field name to search in with df=wordin your URL, or use the edismax query parser (defType=edismax) and the qf parameter (query fields). qf allows multiple fields and giving them a weight, but in your case it'd just be qf=word.
Second - what you're doing seems to replicate what Lucene is doing internally, so I'm not sure why you'd do it this way (each word is what's called a "token", and each count is what's called a term frequency). You can write a custom similarity to add custom scoring based on these parameters.
I use solr , latest version.
I run text query with "OR" condition by different fields.
I want to have indication due to which field the document return.
How can I do it?
Faceting could be an option here. In your Solr Query set "facet" to true. You also need to set "facet.field" to the fields that you are including in OR search criteria. The Solr Response will then show you how many results are returned for each of the search fields.
Here is the reference - https://cwiki.apache.org/confluence/display/solr/Faceting
-Amit
If you only want to specify which fields do you want to get back in the response, then you're after the fl parameter, if you do a request like:
http://localhost:8983/solr/demo/query?
q=title_t:black
fl=author,title
You're indicating that you only want to get back the author and title fields, something like:
{"response":{"numFound":2,"start":0,"docs":[
{
"title":"The Black Company",
"author":"Glen Cook"},
{
"title":"The Black Cauldron",
"author":"Lloyd Alexander"}]
}}
All:
I am pretty new to SOLR, I upload some documents which have "season" in content field(store but not indexed, copy to text field) and in title field(store and indexed copy to text field)
When I use basic query without dismax like:
http://localhost:8983/solr/collection1/select?q=season&rows=5&wt=json&indent=true
It works very well and return correct results, but when I want to boost those documents which have more "season" in content rather than title, I used dismax like(I guess the way I use it is totally, cos the content is not indexed, but I at least expect certain return result even incorrect ):
http://localhost:8983/solr/collection1/select?q=season&rows=5&wt=json&indent=true&defType=dismax&qf=content%5E100+title%5E1
There is no match result returned, I wonder if anyone could help me with this? Or could anyone show me how to use dismax correctly
Thanks
In your second query you specify the "content" field as the one and only query field but earlier you write that this field is stored but not indexed. If a field is not indexed you can not search against it.
I faced the same problem. Tracked it down to the schema definition where for dismax to work, field type should be text and not string
for e.g text_general,text_en_splitting,text_en
Its because of the tokenizers used for this field types.
-->
I am getting unexplainable results doing filtered query.
when entering "searchstring" into fq w/o specifying field and got a lot of hits. The schema.xml sets the "content" field as the default search field. However, the returned results is different when I enter content:"searchstring". Rather, it is the same if I enter url:"searchstring".
How did solr get configured to use url as the default fq search field? I checked into schema.xml but can not figure out how this was set.
does any one know?
It is most likely in your solrconfig.xml as default field. Just to be sure which field the fq is searching by default in your environment, run the query with debug=true option and in the debug response you will see an entry with "parsed_filter_queries". This will provide actual field on which it is filtering.
I have ngram-indexed 2 fields (columns in the database) and the third one is my full text field. Now my default text field is the full text field and while querying I use dismax handler and specify in it both the ngrammed field with certain boost values and also full text field with a certain boost value.
Problem for me if I dont use dismax and just search full text field(i.e. default field specified in schema) synonyms work correctly i.e. ca returns all results where california is there whereas if i use dismax ca is also searched in the ngrammed fields and return partial matches of the word ca and does not go at all in the synonym part.
I want to use synonyms in every case so how should I go about it?
Ensure you already correctly configured the "SynonymFilterFactory" filter in your ngram field's query analyzer.
If still doesn't work, the Solr admin's analysis interface can give more details of the tokenize/filter procedures, through which can check if the Synonym part already works as expected.