MoreLikeThisQuery using SolrTemplate in Spring data - solr

My question is very simple, can a More like this query be performed using SolrTemplate in Spring data? I cannot find the class MoreLikeThisQuery like the one in Elastic Search.
Thanks in advance.

No, there is no functionality inside Spring Data Solr, however, this is relatively easy to add such functionality by yourself.
In short terms, you need to add a Solr Server RequestHandler, that will use default solr.MoreLikeThisHandler and just invoke this handler from the repository.
There is a nice blog post about it here, containing all needed details.

Related

CakePHP 3 - Where is custom datasource?

I have a large number of CakePHP 2 web applications, many of them use remote data over the custom DataSource. I'm reading the documentation of CakePHP 3, but I can not find instructions for creating custom datesource.
My next project also requires a custom DataSource (ArangoDB), so I planned to build it with the new version of CakePHP.
Please do specify where and how to build a DataSource in CakePHP 3.
Thank You.
Just look at the code of any existing database driver and see how it is built? There is nothing in the book yet about how to create your own datasource.
ArangoDB seems to be yet another NoSQL DB, so take a look at how this Elastic Search datasource is done. By a quick look I think you can use it as a base for your implemention, they seem to be similar.
I was facing the same problem so I decided to write my own models in CakePHP 3.x. If you want you can use it from here. hope you like it.

How to implement solr and solarium in cakePHP

I have to integrate Solr search in one of my CakePHP project. I have installed Solr and Solarium using composer but could not find how to start searching using Solr. Is there any example code in CakePHP?
First thing you need to figure out is how to expose the Solarium API in your CakePHP application. Typically this means saving some third-party PHP files into the Vendor directory of your application (take peek here for more information).
Once you've done this, you have two options:
Interact with the Solarium API directly in your controller's actions.
Implement a Solarium datasource so you can use CakePHP's model constructs.
Option 1
This option is less consistent with how the developers of CakePHP would like you to do MVC and you will have to generate a fair bit of code each time you want to put something in Solr or query it (e.g. connect to the Solr database). If you have minimal interaction with your Solr database, then I would recommend going down this route. Perhaps you could wrap up your access in separate helper class or function so instead of this:
public function void myControllerAction() {
// create a client instance
$client = new Solarium\Client($config);
// get a select query instance
$query = $client->createQuery($client::QUERY_SELECT);
// this executes the query and returns the result
$resultset = $client->execute($query);
// expose the result set to your view
$this->set('records', $resultset);
}
you could have this:
public function void myControllerAction() {
$resultset = solarium_get_records();
// expose the result set to your view
$this->set('records', $resultset);
}
Option 2
This option is a bit more involved and requires you to write a Solarium datasource just like the developers have written for MySql and Postgres. This does require you to thoroughly understand the inner workings of CakePHP's model engine but by taking a look at how the other datasources work, it shouldn't be rocket science. Rest assured that if you did this and made your code open-source, other developers will love to use it in their own CakePHP applications!
The benefit of this approach is that you will successfully abstract your application from the specific database implementation. So if you decided you didn't fancy using Solr and preferred a different search engine, you could migrate your data, write a new datasource (if one didn't exist already) and you're all set.
This probably doesn't exactly answer your question but instead steer you in the right direction and highlight some aspects you should consider.
I have integrated Solr with Option 1. However option 2 is doable but due to some time restriction I have to choose option 1. We can directly include Solarium vendor and include its class in our controller wherever required and use solr's add/get queries.
There are basically 3 major steps: 1: Install Solr. 2: Install Solarium using composer 3: User your scripts within controller or component files to get results.
You can get complete reference and example codebase from here:
http://findnerd.com/list/view/Solr-integration-in-CakePHP-with-solarium-client/1946/
Thanks.
I've integrated Solr using Sam's Option 2 (as DataSource)
https://github.com/Highstrike/cakephp-solr-datasource
You can also find there instructions on how to use it with examples

Search across all namespaces in appengine

Is there a way for me to search across all the namespaces in google app engine? Conceptually its not possible but wanted to check with the community.
Currently, I iterate through all namespaces and query each of them. Its time consuming and slow.
Not possible with standard datastore queries. Options would be to use Search API, or export to BigQuery.
Not possible, as Gwyn is pointing out. I DO see that there is a bug for this feature to be added in Google's Public Issue Tracker (namely, this issue)
It's also not possible using the Search API. My understanding is that namespaces are designed for isolation.
You could assign the same search document to two index. One generic or default and other isolated.
Then just search over the generic one, for example:
generic = search.Index("all_docs")
specific = search.Index("specific", namespace="sample_namespace")
generic.put("search_document")
specific.put("search_document")

Fetch database comments using hibernate

I need to fetch database comments from a postgresql using hibernate. I have read the documentation but could not find any hints on how to get the comments. Basically I am generating Pojos and would like to use the comments in the database to put them into the Java classes.
Thanks in advance!
I seems hibernate does fetch DB comments when using the hbm2hbmxml tool but is not using that when generating POJOs (hbm2java). You can override the freemarker templates used to generate POJOs and add the comments there.

Is it possible to modify a schema using the rest API in Apache Solr?

I think the title is self-explanatory.
I don't see anything on the Apache Solr wiki that suggests you can maintain the schema of an Apache Solr instance using the ReST API, but maybe (hopefully) you know something I don't.
I just found a section on the Solr wiki where they describe this exact feature for release 4.4 (which is not released yet).
It does have some prerequisite configuration on the Solr instance, but it does allow you to add fields to the schema. Based on that information, I can't see why they won't eventually extend the functionality to allow you to delete as well. I guess we will have to wait and see.
Here is the link to that section: http://wiki.apache.org/solr/SchemaRESTAPI#Adding_fields_to_a_schema. It also references this JIRA issue: "In preparation for dynamic schema modification via REST API, add a "managed" schema facility".

Resources