You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by "Banerjee, Soumya J" <So...@in.tesco.com> on 2016/07/01 06:49:43 UTC

Starting the embedded Solr server in Oak

Hi,
I am facing a problem in getting started with embedded Solr server in Oak v1.4.1 (that is bundled as part Oak). I understand that the embedded Solr server is started in-memory without any HTTP binding (for security reasons). I am setting the index properties at the time of our  repository initialization as follow:

index = oakIndex.child(propertyName + "-Index");

index.setProperty("jcr:primaryType", "oak:QueryIndexDefinition", Type.NAME)
     .setProperty("type", "solr")
     .setProperty("async", "async")
     .setProperty("propertyNames", Collections.singletonList(propertyName), Type.NAMES);
     .setProperty("reindex", true, Type.BOOLEAN);
Property name here is typically a metadata field name from my document e.g. createdBy
My questions are:

1.       How do I know that the embedded Solr server is running?

2.       If it is running why don't I see solr indexes under oak:index/PropertyName-Index created when I post a document?
Please let me know if I have to add any extra parameters to start the embedded solr server in Oak.

Thanks & Regards,
Soumya Jyoti Banerjee
(Sr. Software Engineer)
Ring : 8722181100
[cid:image002.jpg@01D0E640.ECCD3030]


Re: Starting the embedded Solr server in Oak

Posted by Tommaso Teofili <to...@gmail.com>.
Il giorno ven 1 lug 2016 alle ore 08:49 Banerjee, Soumya J <
Soumya.J.Banerjee@in.tesco.com> ha scritto:

> Hi,
>
> I am facing a problem in getting started with embedded Solr server in *Oak
> v1.4.1* (that is bundled as part Oak). I understand that the embedded
> Solr server is started in-memory without any HTTP binding (for security
> reasons). I am setting the index properties at the time of our  repository
> initialization as follow:
>
>
>
> index = oakIndex.child(propertyName + "-Index");
>
> index.setProperty("jcr:primaryType", "oak:QueryIndexDefinition", Type.NAME)
>      .setProperty("type", "solr")
>      .setProperty(“async”, “async”)
>      .setProperty("propertyNames", Collections.singletonList(propertyName), Type.NAMES);
>      .setProperty("reindex", true, Type.BOOLEAN);
>
> Property name here is typically a metadata field name from my document
> e.g. *createdBy*
>
> My questions are:
>
> 1.       How do I know that the embedded Solr server is running?
>
as you also mentioned, there's no endpoint exposed.
You can check the logs and / or have a look at the Solr home directory on
the file system (in your case you should have a 'solr' directory in the
base directory you started the JVM from).

> 2.       If it is running why don’t I see solr indexes under
> oak:index/PropertyName-Index created when I post a document?
>
are you committing your changes after having created the index?

> Please let me know if I have to add any extra parameters to start the *embedded
> solr server* in Oak.
>
> if you run Oak inside OSGi and plan to have only one Solr index defined,
you can use the SolrServerProvider OSGi service and set its type to
"embedded".

If you instead either to use more than one Solr index within your
repository or do not run inside an OSGi container you should add a 'server'
child node to the 'solr' index with "solrServerType' property set to
'embedded', see full code snippet below:

Tree oakIndex = root.getTree("/oak:index");
Tree index = oakIndex.child(propertyName + "-Index");
index.setProperty("jcr:primaryType", "oak:QueryIndexDefinition", Type.NAME)
     .setProperty("type", "solr")
     .setProperty(“async”, “async”)
     .setProperty("propertyNames", Collections.singletonList(propertyName),
Type.NAMES);
     .setProperty("reindex", true, Type.BOOLEAN);
Tree server = index.addChild("server");
        server.setProperty("solrServerType", "embedded");

root.commit();

I hope this helps,
Regards,
Tommaso

>
>
> *Thanks & Regards,*
>
> *Soumya Jyoti Banerjee*
>
> (Sr. Software Engineer)
>
> *Ring : 8722181100*
> [image: cid:image002.jpg@01D0E640.ECCD3030]
>
>
>