Does Solr have a folder watcher ? - solr

I am using Solr 7.2 to index 'document files' using Post.
However, i want this to rerun every time there is a change to the document folder.
So i am using Jenkins with Folder Watcher trigger (FSTrigger) which calls the POST to re-index like this :-
/opt/solr/bin/solr delete -c resumes
sudo -u solr /opt/solr/bin/solr create -c resumes -d /opt/solr/example/files/conf
/opt/solr/bin/post -c resumes /home/chak/Documents
Is there a folder watcher in Solr itself, so i can avoid using Jenkins ?

No, Solr does not have any watch capabilities - seeing as it's also meant to be running as a cluster on multiple server, I'm pretty sure that's functionality that would be considered to be external to Solr (possibly integrated into the post tool if any).
That being said, you don't have to use something as complex as Jenkins to implement that. Using inotifywait you could implement the same functionality with a couple of lines of bash.

Related

How to add a new machine to an already running solrCloud?

So, I have two instance of solr node running along with a embedded zookeeper on a single machine using the link Set up solrCloud. Now I want to add a new machine to this cluster. I run bin\solr start -cloud -s ./solr -h newMachineIP -p 9000 -z oldMachineIP:9983. It shows successful startup, but when I create a new collection it gives me an error saying "Server refused connection at: http://newMachineIp:9000/solr"
just a guess but... does C:\path\to\di‌​r\solr-7.1.0\solr-7.‌​1.0\server\solr\gett‌​ingstarted contain any spaces? If so, install Solr into a path with no spaces, this has been an issue before in Windows, and it's possible it still is in some code paths. Solr on Windows get much less testing than on linux.

SOLR full-import not working when running using lynx command

I want to setup a cron in Amazon EC2 Linux to run a SOLR full-import at 12:15AM every night.
Before I setup the cron I tried testing in the terminal whether it is working or not. I used below command to test
/usr/bin/lynx http://amzon-instance-ip:8983/solr/work/dataimport?command=full-import
Output of the command:
[1] 15153
But when I go to below url to check whether the full-import actully initiated. I see the full-import command is not running.
http://amzon-instance-ip:8983/solr/#/workb/dataimport//dataimport
Anyone can help me why the SOLR full-import not running with lynx command? Am I using lynx correctly or do I need to use a differnt approach? Any Suggestions please.
I spent some time on internet searching the solution for why a url not working with lynx but could not find the solution.
Thanks for #Oyeme suggestion, I got two ways to get my URL running using linux curl and wget commands.
Using linux curl command:
curl -s ' http://amzon-instance-ip:8983/solr/work/dataimport?command=full-import&clean=false' > /dev/null
Using linux wget command:
wget -O /dev/null ' http://amzon-instance-ip:8983/solr/work/dataimport?command=full-import&clean=false'

In Solr5.5, easiest command-line way to create core in localhost using existing conf

I have a git repository containing a solr/conf folder with solrconfig.xml and schema.xml. I've managed to create a local solr core and copy these files into it, but I expect there is an easier way than what I did, which was basically:
solr create -c mycorename
cp solr/conf/schema.xml /usr/local/Cellar/solr/5.5.0/server/solr/mycorename/conf
cp solr/conf/solrconfig.xml /usr/local/Cellar/solr/5.5.0/server/solr/mycorename/conf
...and restart the core to have the changes take effect.
My solution is not that complicated, but it requires a lot of specific knowledge of folders etc. and I'd like something simpler. Ideally, I would prefer that the core is created in-place in my existing folder.
If that is not possible I would like to have a simpler way that does not require knowledge of the specific solr folders on a developer's workstation. Maybe a couple of curl commands.
Your question is about best practice for creating a core from command line.
You already use
bin\solr create -c mycorename`
but at time you need a restart, because you change the config after creation.
Solr can copy your config files and creating the core in one step:
bin\solr create_core -c mycore -d c:/tmp/myconfig
If you are using SolrCloud you could work even more folder independent:
Add configuration folder to zookeeper
Create collection with this configuration
see also How to create new core in Solr 5?
To create Solr core, use solr script ran with solr user privileges, e.g.
sudo -u solr ./bin/solr create -c mycorename

Do I need to create schema.xml when creating a new core in Solr?

I am running Solr 5.3.0 and I have created a new core using the command bin/solr create -c collection1.
However, I noticed there is no schema.xml file anywhere for that core in the collection1/conf folder.
Do I need to create the schema.xml from scratch each time I create a new core?
What is the best way to do this? Copy the one from {SOLR_INSTALLATION}/server/solr/configsets\basic_configs\conf and modify the schema.xml to suit my needs?
Thanks
Solr 5.3 by default will create a managed schema without a schema.xml; you will then need to create everything you need in it via REST calls to Solr. You can read more about it here.
If you wanted to have the actual schema file you will need to create your collection like so:
bin/solr create -c collection1 -d {SOLR_INSTALLATION}/server/solr/configsets/basic_configs
You can learn more about the options to create a collection by doing:
bin/solr create_collection help
Solr 5 creates schema automatically for you and it is known as managed schema
In case you need to specify your own schema then you can use the below curl command
curl -X POST -H 'Content-type:application/json' --data-binary '{"add-field": {"name":"order_count", "type":"int", "multiValued":false, "stored":true}}'
name : the name of your column or field
type : data type of field
Similarly you can run curl commands for all the fields
You can run this command after creating your solr collection using solr create -c command

On Linux CentOS 7 OS how schedule jobs to run drush to re-index solr, run cron and clear cache for drupal 7 sites

HI a newbie to server management... We need to automate hourly script to run drush to re-index solr, run cron and clear cache on multiple servers. I'm sure there has to be .bat file or something?
At first: You have no '.bat' files in any unix system (but ofcourse you can write scripts named something.bat, but nothing special happens ;-)).
You need to have drush installed somewhere in your sytem. I use to install it in /usr/local/share/drush and put a link from /usr/local/share/drush/drushto /usr/local/bin/drush. Then run crontab -e to edit the schedule. An editor is launched inside your console window. If it shows an empty window or the file contains only lines starting with "#", then put
MAILTO=your.mail#example.com
PATH=/usr/local/bin:/bin:/usr/bin:$HOME/bin
#daily drush #live -q -y cron > /dev/null
In this case drush cron is executed daily for a drupal installation with a site-alias #live. The output is sent to /dev/null, so that I do not get any error messages.
PS: Get familiar with the cron systems and the crontab command as well as shell scripting. They are unix' standard tools and are needed for those kind of tasks.
PS2: You also want to know the concept of drush site-aliases. Run drush topic docs-aliases to learn more about it.

Resources