I am using Solr 1.3.This is the schema.xml of Solr 1.3. (http://pastebin.com/NwEy9Kz6). If i search for 'Hero' (e.g. +movieName:"Hero"), the Top most search document which contain the word "Hero", not the exact matching "Hero" document. e.g. Heroes, The Hero, Hero Hiralal, Heroes 2, Herold, Hero.
I want the exact match word appear on the top of the search result. Please suggest.
You need to create a second field in your document that has not been tokenized. This can be accomplished using the string type from the default schema.
If you only want to return exact matches you can just search on this field. If you would like to return all matches, but return this one first you can search both fields. Matching both fields results in a boosting effect.
Here are some examples of field definitions:
field name="manufacturer" type="text_ws" indexed="true" stored="true"
field name="manufacturer_exact" type="string" indexed="true" stored="false"
Related
I am running solr 7.7.2 and I am trying to apply facet on a particular field
"display-classification_en_string_mv" (type="string" indexed="true" stored="false" multiValued="true")
The problem is when I try to apply facets on this field, with
acet=true&facet.field={!ex%3Dfkdisplay-classification}display-classification_en_string_mv&facet.mincount=1&facet.limit=10&facet.sort=count,
The actual facet count I get for a variant of this field "maxi dress" is 100 as shown below.
Now when I try to add a filterquery (fq) like this
fq={!tag%3Dfkdisplay-classification}+display-classification_en_string_mv:"Maxi+Dress"
the actual count increases to 101.
One thing to note is I am using a collapse query to group documents having same value in a field of type="string" indexed="true" stored="true".
This count mismatch happens only when the collapse query is applied, and without the collapsing in place, the count remains same in both cases.
Please let me know if I am missing something or any error in implementation which might lead to this.
Apparently, the collapse query selects one of the documents in the group as a leader and selects it for counting facets, and in one of the group, the leader which was getting selected didn't have the field considered for facets.
I am very beiginer in Solr and I am trying to do query on my data. I am trying to find data with name=plant and sort it by maximum price
my schema for both name and price is text type.
for eg let say data is
name:abc, price:25;
name:plant, price:35;
name:plant,price:45; //1000 other data
My Approach
/query?q=(name:"Plant")&stopwords=true
but above is giving me result of plants but I am not sure how to sort result using price feild
Any help will be appreciated
You can use the sort param for achieving the sorting.
Your query would be like q=(name:"Plant")&sort=price desc
The sort parameter arranges search results in either ascending (asc)
or descending (desc) order. The parameter can be used with either
numerical or alphabetical content. The directions can be entered in
either all lowercase or all uppercase letters (i.e., both asc or ASC).
Solr can sort query responses according to document scores or the
value of any field with a single value that is either indexed or uses
DocValues (that is, any field whose attributes in the Schema include
multiValued="false" and either docValues="true" or indexed="true" – if
the field does not have DocValues enabled, the indexed terms are used
to build them on the fly at runtime), provided that:
the field is non-tokenized (that is, the field has no analyzer and its
contents have been parsed into tokens, which would make the sorting
inconsistent), or
the field uses an analyzer (such as the KeywordTokenizer) that
produces only a single term.
I have a document which has title, stockCode, category fields.
I have different field types (and analysis chains) for each. For instance title has EdgeNGram 2 to 20, category has EdgeNGram 3 to 10 with different range and stockCode just has lowercase filter.
So that, I don't want to search from documents with keyword "sample" with building the query like title:sample OR stockCode:sample OR category:sample.
I'd like to search with just "q=sample".
I copied my fields to text but It does not work. Because all fields analyzed as same. But I don't want to index stockCode as EdgeNGram or any other filters. I'd like to index my fields as I configured and I'd like to search a keyword over them base on my indexes.
I've been researching about that for three days, and Solr has a little bit poor documentation.
You can use the edismax handler, as this will allow you to give a list of fields to query and supply the query by itself. You can also give separate weights to each field for scoring them differently.
defType=edismax&q=sample&qf=title^10 stockCode category
.. will search for sample in each of the three fields, giving a 10x boost to any hits in the title field.
You can find the documentation about the edismax query parser under Searching in the reference guide.
I'm inspecting a Lucene index with Luke.
All documents have a field 'Title' and I would like to do a search for the search expression Title:Power, by which I want to find all documents with a title containing the word Power.
In Luke, I go to the tab "Search" and enter +Title:Power
When searching, there are no results. However, when I search by another field, I do find the document: +ContentType:MyContentType
In the column Title, I can clearly see the value of the document being: Power Quality Guide.
What could be the reasons I'm not finding this document when searching on Title?
There can be a number of reasons. Most common ones:
Title field could just be stored in the index but not indexed for search (Field.Store.YES, Field.Index.NO), unlike for the field for which you can find results (ContentType);
document(s) could be indexed using one analyzer but query is using a different one;
document is indexed using NOT_ANALYZED option which would store a field as a single term
I want to sort the results and scores returning from SOLR search,how I can get scores based on date like below:
Suppose for keywords "football"
12-10-2012 - 3.2
13-10-2012 - 1.5
My solr date filed lis like below:
<field name="published_date" datetimeformat="dd-MM-yyyy" type="date" indexed="true" stored="true"/>
I checked this docs but couldn't find that.
Thanks.
You can pass the sort parameter in the URL
e.g. sort=published_date desc for documents by published date in descending order.
If you want to sort by score and date you can use sort=score desc, published_date desc
taken from the wiki
Although not technically a Syntax difference, please note that if you use
the Solr "DateField" type, any queries on those fields (typically range queries)
should use either the Complete ISO 8601 Date syntax that field supports,
or the DateMath Syntax to get
relative dates. Examples:
timestamp:[* TO NOW]
createdate:[1976-03-06T23:59:59.999Z TO *]
createdate:[1995-12-31T23:59:59.999Z TO 2007-03-06T00:00:00Z]
pubdate:[NOW-1YEAR/DAY TO NOW/DAY+1DAY]
createdate:[1976-03-06T23:59:59.999Z TO 1976-03-06T23:59:59.999Z+1YEAR]
createdate:[1976-03-06T23:59:59.999Z/YEAR TO 1976-03-06T23:59:59.999Z]
NOTE:TO must be uppercase, or Solr will report a 'Range Goop' error.
combine that with this and the job is done :) it's pretty easy, it just requires some tries in the beginning
a little edit: this method allows you to retrieve values based on a date range and apply a score boost to them according to their values. apparently you were asking help on how to retrieve sort on base score and date, so my answer isn't the 100% correct one