Hitesh
Hitesh

Reputation: 3498

Solr facet exclude words from output

Below is my Solr request

localhost:8983/solr/keyspace.table/select?q=*:*&fq=date:[2016-03-01T00:00:00Z TO 2016-03-01T00:59:00Z]&rows=0&wt=json&indent=true&facet=true&facet.field=title

This gives me output like

"facet_counts": {
"facet_queries": {},
"facet_fields": {
  "title": [
    "on",
    24,
    "demand",
    6,
    "gold",
    6,
    "rebounds",
    6,
    "silver",
    6,
    "slips",
    6,
    "subdued",
    6,
    "abuse",
    3,
    "back",
    3,
    "at",
    2,
    .
    .

I want to remove some words from this, for e.g. I want to exclude on and at from the output. There could be many words like this, which I would like to supply to solr, which it should exclude. Is there any way to do this?

On searching, I found and tried something like fq={!tag=title}title:"on" but that did not work, it still returned same output.

Also, by default it returns only 100 words and their count. I want upto 1000 or 2000 words, can we supply the number of words we want as output?

Upvotes: 0

Views: 624

Answers (2)

MatsLindh
MatsLindh

Reputation: 52892

Use a separate field that only have the tokens you want to facet on. You can do this by applying a StopFilter - which you can configure with all the values you want removed. You want to do this at index time, so a re-index will be necessary after adding it to the list of filters.

You can exclude documents from the result by using fq which match the documents that doesn't contain the field (using -term or NOT as the boolean operator).

Upvotes: 0

Bereng
Bereng

Reputation: 734

As per the number of results check: https://wiki.apache.org/solr/SimpleFacetParameters#facet.limit

As per the words you want to exclude you need to go into Solr manual, the exact version you're using, and look for 'stop words' and the different possibilities Solr gives you to achieve what you want.

Sorry I can't be of further help.

Upvotes: 2

Related Questions