Last active
January 22, 2019 16:37
-
-
Save billdueber/a21c527a62ee2fcb512ad537388b61da to your computer and use it in GitHub Desktop.
How to test solr analysis output against live solr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'simple_solr_client' | |
# https://github.com/billdueber/simple_solr_client | |
client = SimpleSolrClient::Client.new("http://localhost:9639/solr") | |
# What do we have? | |
client.cores | |
#=> ['med'] | |
core = client.core('med') | |
# Can get a list of the field types if you like: | |
# core.schema.field_types.map(&:name) | |
# | |
# Get a particular type I want to work with | |
middle_english_text = core.schema.field_type('me_text') | |
middle_english_text.index_tokens("bill thinks small thoughts") | |
#=> ["bill", "thincs", "small", "thovghts"] | |
middle_english_text.query_tokens("Hwætene corn is iset on ʒetacnunge ures Hælendes Cristes") | |
#=> ["hwaetene", "corn", "is", "iset", "on", "zetacnvnge", "vres", "haelendes", "cristes"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment