storing key value pair in multivalued field solr4.0 - solr

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

Related

MongoDB with Apache Solr: Should you index entire collection in Solr? If not then how to get the complete document based on solr index search query

I am using apache solr for field based and for full text search as well.
Should I index entire collection of mongodb in Solr?
If i decide to index only selected fields out of a document of mongo collection in apache-solr, then will I be able to get the complete document from indexed search query?
Two of the properties fields can have in Solr are indexed and stored. In a high level simple way, indexed means they are processed and searchable, stored just means their original content is saved as is and can be retrieved. So for example, you can index the entire MongoDB document into a stored Solr field, then index various other parts of the document into indexed fields. So you could search on those indexed fields, and get the entire document back from the stored field in the result.
Note: fields can be both indexed and stored

Facets in SOLR using text not in document

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.

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?

reindexing json object into solr by adding only unique elements

I have indexed json object into solr using httpclient
and when I tried to index again, duplicate records are getting indexed.
So how to update the records into solr, everytime I index I want to update the records.
Thanks in advance
In your JSON Object include an ID field inside your json object and it should be unique, for example some random number like 65746 . When you will try to index this document again, solr will check for id .If id is same, solr will not index that whole document again . Now the question is how you declare a unique field in solr schema . So for that go to your schema.xml file or managed-schema file which is inside your core configuration and define unique field like this id . Now solr will identify id coming from your JSON as unique , and won't indexed already indexed documents.Hence there will be no duplicate records. Let me know if that helped you :)

Is there any way to convert a solr multifield value to single field for sort?

I have records that have multiple values so I put those fields in a multifield value for its solr document. The issue is I also need to return an ordered list of these values. I have way to many records to pull all document values and sort myself. I tried to create separate solr documents to store just these values with needed information but managing this has become a nightmare. Attempting to keep comments low and managing memory has not been ideal for this solution.
Is there anyway to copy these multifield values into single field values for the same document and sort on these multiple single field values in solr?
Thanks for any help.
doesn't faceting help you? you won't need to have a copyfield for multivalued/non-multivalued, just store them in a multivalued field, facet them and set the sorting criteria for the facet (default: number of occurrencies for each value)

Resources