I'm searching with the following query:
/select?q=:&fq=fld:dddd OR fld:aaaa OR fld:bbbb
where, the field fld is a String type and uniqueKey.
I'm getting results as:
<doc>
<str name="fld">aaaa</str>
</doc>
<doc>
<str name="fld">bbbb</str>
</doc>
<doc>
<str name="fld">dddd</str>
</doc>
Looks like the results But I want the results to be "un-sorted"... meaning, I want the results to be in the order in which I have given in the fq condition. That is, I want the results as follows:
<doc>
<str name="fld">dddd</str>
</doc>
<doc>
<str name="fld">aaaa</str>
</doc>
<doc>
<str name="fld">bbbb</str>
</doc>
How do we do that? Thanks in advance!
If you add score to your fl then you will see that all of them has the same score value, so it is sorted on fld -thats why you see aaaa bbbb dddd-
you can change scoring or give boost on query time, depending on your fl order to get a similar thing but other than those I dont think it is possible to have it without writing a plugin or hacking solr source.
You can also add a RandomSortField to your schema. Then sort the results randomly. See:
http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/schema/RandomSortField.html
EDIT: After re-reading the post, I realize that's not what you're looking for. You might try sorting using a function:
http://wiki.apache.org/solr/FunctionQuery
Related
I am currently using solr 7.1.0. I have indexed a few documents which have a date associated with it.
The Managed schema configuration for that field is :
<fieldType name="pdate" class="solr.DatePointField" docValues="true"/>
<field name="Published_Date" type="pdate" multiValued="false" indexed="true" stored="true"/>
Example of few values are :
"Published_Date":"2019-10-25T00:00:00Z",
"Published_Date":"2019-10-21T10:00:00Z"
Please help me in finding how I could achieve the following
I want to sort the documents based on these Published_Date parameters but only on the day(not the time/timezones)
Sorting on the basis of
"Published_Date":'2019-10-25'
I am still new to SOLR and I've managed to install and index 1000 documents from the database. When I submit a query, the results are returned correctly but the order of the fields are not displayed as how it is defined in the data config file.
Example of data config file:
<field column="id" name="event_id" />
<field column="event_desc_current" name="event_desc" />
<field column="event_cost" name="event_cost" />
<field column="event_sponsors" name="event_sponsors" />
...
Example of results returned:
<result name="response" numFound="7" start="0">
<doc>
<str name="event_desc">Church Fund Raising</str>
<arr name="event_sponsors">
<str/>
</arr>
<str name="event_id">2</str>
<int name="event_cost">428</int>
...
<long name="_version_">1472652516366745600</long></doc>
How can I output the order of the fields as defined in the data config file like this:
event_id
event_desc
event_cost
event_sponsors
...
Typically, the order of the fields should not matter, as you would de-serialize it in a client and the logic of displaying the search results is with the client.
However, if you do want to dictate the order of fields, you could use the fl parameter in your Solr query to get results in the order you prefer.
You could also choose which fields to include in the search field.
Personally, I would recommend that you need not worry about order of fields, and have a client that can consume it in any order. Reason being, if you add a new field to your schema, in the middle, you could potentially breaking the client's logic!
I have a mangeto installation with apache-solr (in linux environment)
When I am searching with a keyword, it shows unrelated products.
Later И figure out that solr is adding a query text and search with that also.
Here is the example:
Below is a part of my solr results xml,
<lst name="debug">
<str name="rawquerystring">bbb</str>
<str name="querystring">bbb</str>
<str name="parsedquery">text:PP text:bbb</str>
<str name="parsedquery_toString">text:PP text:bbb</str>
I search with the keyword "bbb". But in the parsedquery the solr has added an another query string as "PP".
So this is returning the products have "pp" in in description.
How I can prevent this automatically generation of a query text.
I hope you will clear my issue.
Most probably it's a dismax/edismax parser. Query passes the analysis chain as defined for the 'text' field type. Your 'PP' is somehow related to 'bbb', therefore the query is expanded. E.g. it can be a stemmed variation, or a synonym etc.
Check your schema.xml as D_K suggested.
I have xml like this.
<Root>
<a1>
<a>test</a>
<b>
<c>1</c>
<c>2</c>
</b>
</a1>
<a1>
<a>test2</a>
<b>
<c>3</c>
<c>4</c>
</b>
</a1>
</Root>
I will import data from this xml into solr.
I am using XPathEntityProcessor and I want to concate values of nodes <c>.
Which will result in "1,2" and "3,4".
Is there any way to achieve this?
Why do you need to concatenate them? Solr supports multivalued fields out of the box, you just need to declare them that way.
However, if you really do want to do, use DIH to put them into multiValued field and then concat them either with custom/script transformer or with (Solr 4+) update.chain and Update Request Processor. There is one that can concatenate.
It is not possible with XPath in solr.
This query will work with any XPath 2.0-compatible query processors, which solr doesn't seem to be:
//b/string-join(c/text(), ",")
I've very a lot of searching on Google and can not find the answer to this question.
We have Enterprise Magento and are using SOLR. We would like to select a group of products and put them at the top of the search results when they are returned by SOLR. We would use this for clearance products, etc.
My idea was to put the items in to a special non-display category on the backend and to somehow configure SOLR to put a greater weighting on these products for the search results. But I can not see how to do this. I can only see how to weight product attributes.
Anyone have any suggestiogs?
Giving fields different weights is very simple in Solr -- simply add the following to your default requestHandler in solrconfig.xml
<requestHandler name="/select" class="solr.SearchHandler">
<lst name="defaults">
...
<qf>Weighted_Category^3 Lesser_Category^0.5</qf>
</lst>
</requestHandler>
This weighs "Weighted Category" by a factor of 3, should there be a match.
Magento-solr has a built in function to do exactly this.
magento/lib/apache/solr/config/elevate.xml:
<elevate>
<query text="foo bar">
<doc id="1" />
<doc id="2" />
<doc id="3" />
</query>
<query text="ipod">
<doc id="MA147LL/A" /> <!-- put the actual ipod at the top -->
<doc id="IW-02" exclude="true" /> <!-- exclude this cable -->
</query>
</elevate>
QueryElevationComponent