donthurtme
donthurtme

Reputation: 1457

Solr 5 custom field and filter

I'm new to solr. After i tried using Solr 5 client. I want to try Solr 5 source code. So my questions are,

  1. can i create a custom field for my own core on solr 5 by editing schema.xml? if it's possible, please tell me the location (it wasn't in my conf folder, should i create a new one?).
  2. Is there any other method for adding a custom field other than using schema api?
  3. Everytime i try to create a new core and then index the files, there are only currency.xml, elevate.xml, managed-schema(generated schema), params.json, protwords.txt, solrconfig.xml, stopwords.txt synonyms.txt on my conf folder and there's no schema.xml. Did i miss something?
  4. Is there any simple tutorial to explain the custom filter on solr 5?

I really appriciate your answer. Thank's

Upvotes: 0

Views: 551

Answers (2)

Bruno dos Santos
Bruno dos Santos

Reputation: 1361

When you create a core in Solr 5 it comes by default with schemaless mode active. This mode make solr schema not visible and all changes need to be done with schema API. If you want to manage schema by yourself you could rename managed-schema to schema.xml and modify solrconfig.xml to not use schemaless mode. In solrconfig.xml replace

 <schemaFactory class="ManagedIndexSchemaFactory">
   <bool name="mutable">true</bool>
   <str name="managedSchemaResourceName">managed-schema</str>
 </schemaFactory>

by

 <schemaFactory class="ClassicIndexSchemaFactory"/>

Now solr will use schema.xml managed by yourself.

The only mandatory configuration files to use are solrconfig.xml and in your case schema.xml. The other files are used just if you configure some filters using them. If you are using the example schema.xml probably you need to have all these files. But clean the configuration files to have just the fields and field types you really expect to use.

To learn more about filters, tokenizers and analyzers you can take a look at https://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters.

Upvotes: 1

jay
jay

Reputation: 2077

  1. Yes
  2. Manually editing the schema and using the API, are only two ways, as far as i know.
  3. How exactly are you creating this core? Are you using the install_solr_service.sh ? Assuming its a linux system, check /var/solr/configs folder. Thats where the config files are if you ran that script.
  4. Yes of course :) . https://cwiki.apache.org/confluence/display/solr/Apache+Solr+Reference+Guide There is a "Getting Started" section, which should answer all your questions, including where configs are stored, how to use them etc.

Happy Searching!

Upvotes: 0

Related Questions