Facets in SOLR using text not in document - solr

I am indexing word document files in Apache SOLR and would like to use facets. Using Velocity, I'm able to use the facet fields and queries which appear as part of document meta data. I'm interested in using fields which are not part of Meta data as facet fields. Ex: Name is a field that does not appear in the document but I would like to use that as facet field. So what I would get is Facet field Name under which I'll have names like John, Bridget etc along with details of the number of documents in which these names (John, Bridget) appear. Please let me know if it is possible to index documents based on fields that are not part of meta data and how can the same be shown as part of facet fields.

Related

Solr query searching on non-indexed fields

Solr version 6.1.0
Created a schema with some fields as indexed=true on which I specifically want the solr main-query q to search.
And also added more fields, which I just wanted to select, so marked them as stored=true and indexed=false.
Issue now is that, main query q=India is searching on non-indexed fields like country, which I have specified in the image.
See the result below
It is selecting the non-indexed field only when I specify the full value of non-indexed field.
See result for q=Indi
How can I restrict solr from searching on non-index fields?
According to the screenshot above you're copying the content sent to the field country into the field _text_. When you're not giving Solr a specific field to search (i.e. you're not using one of the dismax handlers with qf or not prefixing your term with the field name field:value), it falls back to the default search field. This is set to _text_ by default. This field is indexed, and since you're copying the content from your country field into the _text_ field, the values from country will give a hit.
If you don't want this to happen, don't copy the content from country into _text_, or give Solr the actual field you want to search.

How to get all solr field names after filter is applied?

There is an answer how I can get all solr fields names with curl
https://stackoverflow.com/a/29546298/5165781
So, do get all fields names I do
select?q=*:*&wt=csv&rows=0&facet
But how can I get fields names after I apply a filter?
For example:
if I want all solr fields names for specific date, I try : select?q=*:*&fq="dt":"2016-10-06T00:00:00Z"&wt=csv&rows=0&facet
But it returns all field names across all documents.
So, how can I retrieve fields names with specific filters?

How to use Solr's facet for navigation

I'm new to Solr's faceting. The facet section in the search response sees only contain facet terms and counts, no documents associated. Now, if I would like to find a document which belongs to a facet, do I need to pass the facet in the search query and do the search over again? what is the best way to use facets? Thanks
Yes, you have to issue a new search, typically by adding a filter query, in the form of myfacetfield:"facetterm" to your original request.
If you want the documents belonging to each aggregation bucket delivered up front, you can use grouping instead.

Get possible facet fields with search results

I'm working on improving search which is powered by solr for my e-commerce project. So search queries are performed into Solr and results are returned by Solr.
This is working fine. Now I need to offer a facet on the search results. The first could be category this is easy to implement as Category is common to all product and in the query I make I just enable facet and pass category as facet field.
However, for different nature of products there could be different products and they have few facets defined for them.
I'm clueless as how would I know them in advance and pass it in solr search query? Does solr return all facet field by some queries along with the search results? If yes, how?
If no, then what could be the correct way to proceed further.
Pass all Unique Facet Field Name on which you want to make facet filtering, and you will get all records that have facet field.
Define all the static fieldnames in your facet query search, if there are no hits you will not get any results back for that field.
Pass all the possible fields(on which u need faceting) in Facet Field with facet.mincount=1.. so, you'll get only those fields which has at-least one occurrence in your solr data
http://<hostname>:<portname>/solr/<core_name>/select?q:<fieldname>:<value>&fq=<field_name>:<value>&fl=<field1>,<field2>,<fieldn>&start=0&rows=10&facet=true&facet.field=<field1>&facet.field=<field2>&facet.field=<fieldn>&facet.mincount=1

storing key value pair in multivalued field solr4.0

i am using solr4.0. I want to store key value pairs of attributes in mutlivalued field.
Example: I have some documents (Products) which have attributes as one field and i indexed
attributes as separate documents to power auto suggest . now in some auto suggest i have to show facet count of products also . For this i am using solr joins 4.0 and faceting on attributes. here i want to get the name and id of attributes. how i can achieve this?
The Query is looks like below
localhost:8980/solr/searchapp/select?q=%7B!join+from=attr_id+to=prod_attr_id%7Dterms:red&wt=json&indent=true&facet.field=prod_attr_id&facet=true&rows=1000&fl=product_name,product_id

Resources