Skip to content

Instantly share code, notes, and snippets.

@pslusarz
Last active February 27, 2016 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pslusarz/7de913ac63e36e8983b8 to your computer and use it in GitHub Desktop.
Save pslusarz/7de913ac63e36e8983b8 to your computer and use it in GitHub Desktop.
Solr for text searching in 1..2..3..
Works in Solr 5.3.0
Core is Solr concept for a collection of documents / corpus of data. Replace <core> with your own corpus name.
$ bin/solr start
$ bin/solr create -c <core>
#text is not stored by default
$ curl -X POST -H 'Content-type:application/json' --data-binary '{
"replace-field":{
name: "_text_",
type: "text_general",
multiValued: true,
indexed: true,
stored: true
}
}' http://localhost:8983/solr/<core>/schema
# text documents to be indexed on local folder .../text
$ bin/post -c <core> .../text/
#query through admin interface,
http://localhost:8983/solr/#/<core>/query
#but remember to check "hl" which stands for "highlight" and set hl.snippets=100 in free params box
http://localhost:8983/solr/<core>/select?q=Fabryka&wt=json&indent=true&hl=true&hl.simple.pre=%3Cem%3E&hl.simple.post=%3C%2Fem%3E&hl.requireFieldMatch=true&hl.usePhraseHighlighter=true&hl.highlightMultiTerm=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment