How to remove/exclude a doc based on unqiue id from the solr result - solr

I am using solr4.10 , i have few document ids that must not be displayed from any search query.Could some provide inputs as how this could be achieved.

Try this:
/select?q=*:*&fq=tag_id:367 AND id:[* TO *] -id:(306670 302209)
Add you document ids inside -id:(X, Y, Z) to exclude them.
You can find the answer here.

if you know the ids you can add them in the filter query.
fq : This parameter can be used to specify a query that can be used to restrict the super set of documents that can be returned

Related

Is there a way to exclude fields in Solr?

What is the fl parameter I have to use to get all fields in a document except for "field1" in Solr?
Right now is not possible to define, in the fl parameter, the fields to exclude from the results. You have to define all the fields you want and not put field1 in the list. Another possibility is using the regex syntax, as you can see from the official documentation: https://solr.apache.org/guide/solr/latest/query-guide/common-query-parameters.html#fl-field-list-parameter
A different solution can be to not store the field in Solr, this possibility clearly depends on your field usage.

Match all documents excluding some terms using full Lucene syntax

Our service's default search web page uses the * full Lucene query to match all documents. This is before the user has provided any search terms. There is some data (test data, in our case) that we want to exclude from the search result.
Is it possible to match all documents but exclude a subset of all documents?
For example, suppose we have an "owners" field and we want to exclude documents with the "testA" and "testB" owner. The following query does not seem to work with the match all approach:
Query: search=* -owners:testA -owners:testB&queryType=full&$orderby=created desc
Error: "Failed to parse query string. See https://aka.ms/azure-search-full-query for supported syntax."
When searching for anything but *, this approach works fine. For example:
Query: search=foo -owners:testA -owners:testB&queryType=full&$orderby=created desc
Result: (many documents matched)
I have considered a $filter for this and using $filter=filterableOwners/all(p: p ne 'testa' and p ne 'testb') but this has the following drawbacks:
the index must be rebuild with a filterable field
analyzers can't be used so case-insensitivity must be implemented by lowercasing the values and filter expression
Ideally this could be done using only the search query parameter with a Lucene query text.
I found a workaround for the issue. If you have a field in your documents that always has a value, you can use a .* regex to match all values in the field and therefore match all documents.
For example, suppose the packageId field has a value for all documents.
Incorrect (as posted in the original question):
Query: search=* -owners:testA -owners:testB&queryType=full&$orderby=created desc
Correct:
Query: search=packageId:/.*/ -owners:testA -owners:testB&queryType=full&$orderby=created desc

Select multiple values of same facet using IBM WCS v7 and Apache Solr

We use IBM WCS v7, with embeded Apache Solr. Solr is used as a search engine for our e-commerce based application.
As per a recent requirement, we want to use multi select facet functionality, where the user can check multiple facet attributes, and the corresponding values will be OR'ed to the search result.
Ex- I wish to check Color:RED, Color:BLUE and Color:BLACK in my default Search Results, so that each attribute value will be OR'ed in the resulting search results display.
We use the out-of-the-box SearchDisplayCmd, for our Search functionality, where the field "metaData=" takes care of history of the facets applied, and "facet=" takes care of applying a facet field. For the query param "metaData", it encodes the multiple facets into base64 encoding. It uses a special de-limiter to AND the different facet fields,and restrict the search results.
brand:"POLO" color:"RED" shape:"Oval"
I want to know, if there exists any such de-limiter or any alternatives by using which, I can perform an OR operation, on different values of the same facet attribute, and use "metaData" parameter to maintain a history of the applied facets.
Any help on the same front is highly appreciated. Any other approaches, on applying multiple values of the same facet attribute are also welcome.
Great Thanks in advance.
Regards,
Jitendriya Dash
I recently worked on this: Select multiple values of same facet
I was able to get it also.
Try to find where it hits the tag. The expression builder I used comes OOB. getCatalogNavigationView. Make sure you use the appropriate searchProfile.
Pass the facet param in this way.
<c:forEach var="facetSelect" value="paramValues.facet">
<wcf:param name="facet" value="facetSelect>
</c:forEach
But by this method you will not be able to select values from any other attributes. If someone knows how to select values from the same facet or different facet, pls share.
Update SELECTION column of FACET table to 1 to mark the facetable attribute as multi selectable.
In WCS7+, for enabling multi select facet functionality go to FACET table and set 'SELECTION' column value to 1 instead of 0.
If an attribute is to be made multi select facet, you can make the changes from CMC. Go to the attribute dictionary select the attribute and in facetable properties, check 'Allow multiple facet value'.

Behavior of the OR clause in Solr

My solr index contains documents which have a field named department. This field is a multivalue non-required int field. I want to construct a query whose result must be union of
All the documents that do not contain the field department
All the documents that contain the field department, but the values of the field are restricted to a selected few.
I tried constructing the query that looks like so:
-department:* OR (department:* AND department:(100 OR 200))
This doesn't return any results. Whereas if I just just use
-department:*
or
department:* AND department:(100 OR 200)
, the query seems to work well. In short I'm having trouble understanding the behavior of OR clause in this context. Any pointers?
Checkout SolrQuerySyntax
Pure Negative Queries :-
-field:[* TO *] finds all documents without a value for field
You can try :-
q=-department:[* TO *] OR department:(100 OR 200)
To achieve what you want, I think you can use Solr grouping.
You can give something like,
&q=*&group=true&group.query=department:[100]&group.query=department:[200]&group.query=-department:[*]

Solr filter queries and boosting

Is it possible to boost fields that appear in filter queries (fq=) in Solr?
I have a faceted query that has a tagged filter query something like this:
...&q=*:*&fq={!tag:X}brand:(+"4911")+OR+body:(abc)&facet.field={!ex:X}brand&..
(I facet on brand and the facet is set to ignore the filter query tagged X, so I need to use a filter query.)
I would like to make matches on the brand field score higher than matches on body field in the filter query.
The fields brand and body are multivalued.
I've tried adding bf=/bq= arguments, and I can get brand matches to score higher if I change the filter query to be the main 'q=' query, but I don't seem to be able to influence the score of anything in the filter query. I think I maybe going about it in the wrong way..
Thanks.
Solr "fq"'s do not affect score -- see the wiki. So, you should add your queries to "q" that you actually want to boost. If need be, you can always duplicate a query restriction in both "q" and "fq", as "fq" only acts as a restriction on the results set.

Resources