How can I have multiple collections in Solr - database

Hi I am new to Solr and I'm trying to get my bearings.
Using Solr in my case might not be the best idea or might be a bit overkill but this is just for testing to see how to use it.
I would like to create a database which handles users posts and pages, in mongodb I would have created a collection for users, a collection for post and a collection for pages which would obviously contain the individual documents.
I don't know how would I be able to replicate that in Solr . I have created a core for users which I thought is like a collection in mongodb. To add a post on Pages, do I then create a new core for each or is there another way to separate the data?
Thank you for the advice

Yes you can have separate collection in solr as well.
With the latest version of solr where you can use solr cloud and create multiple collections.
Each collection can handle a separate entity.
Please refer the below links for more details
Solr Collection API
Solr Collection Management

Related

How to specify a particular document to be searched in IBM Watson discovery service

IBM Watson Discovery service
I want to get the set of keywords in a particular document in a collection using discovery service. I tried the below url:
https://watson-api-explorer.mybluemix.net/discovery/api/v1/environments/{environment secret key}/collections/{collection secret key}/query?passages=true&count=10&highlight=true&version=2017-11-07
But, it is fetching from all documents in that collection. How can I specify a particular document to be searched?
It's important to know: The collections can have a lot of documents, so the query will search across all your documents inside your collection that you specified if you won't put a field id inside the query.
According to the IBM Watson Discovery Expert #Anish Mathur you can query for a particular document using a field query.
So something like
enviroment/{id envir}/collections/{id coll}/query?query=id:{document_id}
See the Official API Reference for query with WDS.

Add metadata from database to Solr Index created by Nutch

I have a bespoke CMS that needs to be searchable in Solr. Currently, I am using Nutch to crawl the pages based on a seed list generated from the CMS itself.
I need to be able to add metadata stored in the CMS database to the document indexed in Solr. So, the thought here is that the page text (html generated by the CMS) is crawled via Nutch and the metadata is added to the Solr document where the unique ID (in this instance, the URL) is the same.
As such, the metadata from the DB can be used for facets / filtering etc while full-text search and ranking is handled via the document added by Nutch.
Is this pattern possible? Is there any way to update the fields expected from the CMS DB after Nutch has added it to Solr?
Solr has the ability to partially update a document, provided that all your document fields are stored. See this. This way, you can define several fields for your document, that are not originally filled by nutch, but after the document is added to solr by nutch, you can update those fields with your database values.
In spite of this, I think there is one major problem to be solved. Whenever nutch recrawls a page, it updates the entire document in solr, so your updated fields are missed. Even in the first time, you must be sure that nutch first added the document, and then the fields are updated. To solve this, I think you need to write a plugin for nutch or a special request handler for solr to know when updates are happening.

Can Sunspot/Solr work with different RequestHandlers for different Rails classes?

I have one Rails app with two very different classes that are being indexed in Solr (using Sunspot). One is users and the other is a product catalog. There are specific RequestHandlers that I'd like to use for just the product catalog.
Do I set up two Solr instances with different config? If so, how do I point each class to the right instance?
Otherwise is there a way in Sunspot/Solr to tie a class or request to specific RequestHandlers?
Sunspot does provide the ability to specify the handler, check link.

How can I put my custom URLs to SOLR results

I am trying to index my database data with SOLR and I am successfully indexed it.
What I need is:
I need to put URLs with every results.
The URLs for each result item will be different.
Each result item need to append its item_id (which is available as a field) with its URL.
I am very new to SOLR configurations and SOLR query, so please help to implement a better search result XML.
Thanks in advance.
You can store URL in an additional field (stored=true indexed=false) and then simply retrieve it when you're searching.
Even better if you can compose URLs yourself (if they differ only in ID/primary key) by appending document ID to some fixed URL, that's certainly a better way to go.
That would include altering your page which displays search results.
What kind of application is your Solr integrated with?
Where are those documents of yours stored? In a db? How do you get to them through your application?

How to implement a custom sorting in solr using external database data(eg. user's rating data)?

I hava a problem with solr,i wanna sort the search result by the fields in solr's document and
some fields in db. is there anybody who can help me,thanks!
Add those fields you have in your database to Solr, then let Solr do the sorting.

Resources