biblescholar

package module
v0.0.0-...-b34a279 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 10 Imported by: 0

README

A go application using bleve to index tsvs of Bible verses. Uses go modules and go 1.13+.

Basic usage

Building
# Do everything
make

# Just build for mac
make darwin
Indexing
# Run the index command using ESV tsv files
./artifacts/biblescholar-darwin-amd64 index -d ../scrape
# Use the built in bleve search tool to query the index
# After "go install github.com/blevesearch/bleve/cmd/bleve"
bleve query verses.bleve "for God so loved the world"
Running server
# Start server
./artifacts/biblescholar-darwin-amd64 server -i verses.bleve

# Example alexa request
cat test/exampleAlexaRequest.json | jq .

# Example alexa response
curl -s -X POST localhost:8000/alexa/search -d '@test/exampleAlexaRequest.json' | jq .

Working with ELB

Basic tooling
# Install tools
pip install awscli
pip install --upgrade awsebcli

# Add a file that exports env variables
# Setting up the ~/.aws/credentials and ~/.aws/config files didn't work for me for `eb` even though they worked for `aws` commands
vi .aws

# Set this as the active profile
export AWS_DEFAULT_PROFILE=biblescholar

# Initialize
eb init
Dockerizing

I did local testing with docker-machine.

# Build
docker build -t biblescholar .

# Run docker container
# DO NOT try to run with the index mounted as a volume. Bleve will panic when it tries to work with a fs mutex. :(
docker run -it -d --name biblescholar -p 8000:80 biblescholar

# Test request
curl localhost:8000

# Try a more complex request
curl -s -X POST localhost:8000/alexa/search -d '@test/exampleAlexaRequest.json'
Domain name

Running on amazon with urls

# Alexa url will reject your request due to required cert validation in production
curl -s -X POST "$url/alexa/search" -d '@test/exampleAlexaRequest.json' | jq .

# This works though
curl -X GET "$url/search?q=cats%20dogs&size=2&highlight" | jq .

TODO

Nice to haves
  • look into streaming back a recording of a verse (from S3) instead of having alexa read it

  • read a section of scripture

    // optionally "from the {translation} translation"
    range
    - read {book} {chapter} {verse} to {verse}
    - read {book} chapter {chapter} verse {verse} to verse {verse}
    single
    - read {book} {chapter} {verse}
    - read {book} chapter {chapter} verse {verse}
    chapter
    - read {book} {chapter}
    - read {book} chapter {chapter}
    

Documentation

Index

Constants

View Source
const DefaultIndexName = "verses.bleve"

Variables

This section is empty.

Functions

func CreateOrOpenIndex

func CreateOrOpenIndex(indexName string) bleve.Index

func IndexFromTSVs

func IndexFromTSVs(index bleve.Index, dirpath string) (int, error)

Types

type Verse

type Verse struct {
	Book    string
	Chapter int
	Verse   int
	Text    string
	Version string
	// Create a string that includes version and book
	// We save this field because we can't do nested aggregations, but we do want to get book per version for visualizations
	VersionBook string
}

func NewVerseFromLine

func NewVerseFromLine(line []string) *Verse

From a line in a tsv/csv

func (*Verse) Id

func (v *Verse) Id() string

func (*Verse) Type

func (v *Verse) Type() string

Implementation so that items of this type are bound to the correct mapping https://godoc.org/github.com/blevesearch/bleve/mapping#Classifier https://github.com/blevesearch/bleve/blob/v0.5.0/index.go#L87

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL