SOLR Facet Search Results - solr

Ive got following schema.xml
...
id
book
pages
genre (horror,action)
...
Is solr able to return results like this?
genre;books;pages
horror(genre);12(books);124543(pages)
action(genre);2(books);437(pages)
As you can see i want to facet over more than one field. The only thing i got work is the facet search over genre and books. But i want to have the pages as a sum also in my results.
Is Solr able to do this?
Thanks!

you can check for Solr Pivot Faceting which will provide you with hierarchy facets.
You can check if you get the pages, the summing can be done at Client side.

Related

Solr 6.1 - Get all token counts for a Facet field across all documents

I have a TextField in my solr schema.xml on which I want to run faceting and find out counts for every tokens in that field across all the documents. Is there a way to get this? I tried following and I thought it was working until I found out that it's not a complete list of tokens that I am getting form this query:
http://solrnode1:8983/solr/mycollection/select?facet.field=PRODUCT_NAME&facet=on&indent=on&q=*:*&wt=json&rows=0
For example, there is one document in that field that says "Education Services 2014" but I don't see any facet token for 'education' with its count. Interestingly if I change my query parameter to q=PRODUCT_NAME:*education* instead of q=*:* then it shows up in faceting with count! I am not sure what's happening here. Am I missing something here?
I think it's a facet.limit which is by default 100. I increased it and its getting more tokens and counts now.

Include singular search results when search for plural in Solr

I'm working with Solr 4.1, and got it working correctly. I have the terms in the document which contains "school". It gives search result correctly when searching for "school". However, I want Solr to include these results when searching for "schools".
So basically I want Solr to include singular terms in its search results when searching for plural terms.
Any idea how to do it?
You need to apply stemming to your indexed fields in order to achieve this behavior. Please see the Stemming Wiki Page for a complete explanation and an example fieldType to support stemming.

Difference between Solr Facet Fields and Filter Queries

I am using SolrMeter to test Apache Solr search engine. The difference between Facet fields and Filter queries is not clear to me. SolrMeter tutorial lists this as an exapmle of Facet fields :
content
category
fileExtension
and this as an example of Filter queries :
category:animal
category:vegetable
categoty:vegetable price:[0 TO 10]
categoty:vegetable price:[10 TO *]
I am having a hard time wrapping my head around it. Could somebody explain by example? Can I use SolrMeter without specifying either facets or filters?
Facet fields are used to get statistics about the returned documents - specifically, for each value of that field, how many returned documents have that value for that field. So for example, if you have 10 products matching a query for "soft rug" if you facet on "origin," you might get 6 documents for "Oklahoma" and 4 for "Texas." The facet field query will give you the numbers 6 and 4.
Filter queries on the other hand are used to filter the returned results by adding another constraint. The thing to remember is that the query when used in filtering results doesn't affect the scoring or relevancy of the documents. So for example, you might search your index for a product, but you only want to return results constrained by a geographic area or something.
A facet is an field (type) of the document, so category is the field. As Ansari said, facets are used to get statistics and provide grouping capabilities. You could apply grouping on the category field to show everything vegetable as one group.
Edit: The parts about searching inside of a specific field are wrong. It will not search inside of the field only. It should be 'adding a constraint to the search' instead.
Performing a filter query of category:vegetable will search for vegetable in the category field and no other fields of the document. It is used to search just specific fields rather than every field. Sometimes you know that the term you want only is in one field so you can search just that one field.

how to Index URL in SOLR so I can boost results after website

I have thousands of documents indexed in my SOLR which represents data crawled from different websites. One of the fields of a document is SourceURL which contains the url of a webpage that I crawled and indexed into this Document.
I want to boost results from a specific website using boost query.
For example I have 4 documents each containing in SourceURL the following data
https://meta.stackoverflow.com/page1
http://www.stackoverflow.com/page2
https://stackoverflow.com/page3
https://stackexchange.com/page1
I want to boost all results that are from stackoverflow.com, and not subdomains (in this case result 2 and 3 ).
Do you know how can I index the url field and then use boost query to identify all the documents from a specific website like in the case above ?
One way would be to parse the url prior to index time and specify if it is a primary domain ( primarydomain boolean field in your schema.xml file for example).
Then you can boost the primarydomain field in your query results. See using the DisMaxQParserPlugin from the Solr Wiki for an example on how to boost fields at query time.

Get facet results only in Solr

I am trying to make search on my database using Solr, and i need to build a facet for the date of the articles(2011-6-12,2011-7-1 ..etc) and another facet for category(sport, news..etc) i built my php code using apache_solr_service and every thing is fine till now, i can do search for my data in the database, but i want to use facet to filter the articles that are created in specific date or to get the articles that belong to a specific category,
i used:
http://localhost:8888/solr/collection1/select?facet=true&facet.query=datecreated:2011-6-21&facet.mincount=1&wt=json&json.nl=map&q=ruba&start=0&rows=10
its returned all the articles that have 'ruba' word and give me the count of articles that have been created in 2011-6-21.
what i need is to get only the articles that have ruba word AND are created on 2011-6-21, i want only facet results to be returned
Try using filter query, fq=datecreated:2011-6-21 instead of facet

Resources