GithubHelp home page GithubHelp logo

howm-wiki-search's Introduction

Howm indexing

Emacs Howm mode is great for keeping notes, and it has some searching built in, but it isn't documented on the home page, so I decided to index my Howm wiki to make it searchable in Elasticsearch. The steps below get everything set up and all my notes indexed in <5 minutes, not counting time to download Docker images.

Start elasticsearch+kibana.

docker-compose up

To be able to search by date, add a custom date mapping before ingesting. Note that timezones will be off. I haven't looked into how to fix that yet.

curl -X PUT "localhost:9200/wiki" -H 'Content-Type: application/json' -d'
{
    "mappings": {
        "dynamic_date_formats": ["yyyy-MM-dd HH:mm:ss"]
    }
}
'

The indexing scripts are written to run as a pipeline. This works to ingest the entire wiki:

./find-all-entries.sh | \
while IFS='$\n' read -r oneline; do \
    echo "$oneline" | ./parse-entry.sh | ./ingest.sh || { echo "Something went wrong"; break; }
done

The first script outputs a line per file to process. The second outputs two lines per file. That's why the loop has to be where it is. If I changed parse-entry.sh to output a single line encoded somehow, then both downstream scripts could loop and read lines from stdin themselves. However, then I don't think I could avoid loading the whole line into memory in ingest.sh, and right now the payload from stdin is passed right along to curl to keep it streaming the whole way. What a dilemma!

See some indexed docs:

curl -X GET "http://localhost:9200/wiki/_search?pretty" \
    -H 'Content-Type: application/json' \
    -d '{"_source": {"excludes": ["content"]}}'

To see the data in Kibana, create an index pattern that matches the index:

curl -X POST "localhost:5601/api/index_patterns/index_pattern" \
    -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '
    {
        "index_pattern": {
            "id": "my-wiki-index-pattern",
            "title": "wiki",
            "timeFieldName": "createTime"
        }
    }'

Then go to http://localhost:5601/app/discover#/?_g=(time:(from:'2014-12-01T06:00:00.000Z',to:now))&_a=(columns:!(title),index:my-wiki-index-pattern) to see the entries. Kibana might ship with a default index pattern, or I might have created it accidentally.

To start from scratch, delete the wiki index and index pattern do it all again:

curl -X DELETE "http://localhost:9200/wiki" \
    -H 'kbn-xsrf: true' "localhost:5601/api/index_patterns/index_pattern/my-wiki-index-pattern"

howm-wiki-search's People

Contributors

zzantozz avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.