This is ruby. This example assumes you are on something like a unix/linux system (or the part that sees if the files are text based or not will fail)
To run the example:
Save the three files to a directory
Install ruby on the command line type:
gem install bundler
bundle
run
ruby indexer.rb
to index all the files in the current directory and in its subdirectories that are text based
run
ruby index.rb
to get a nice web page with a search form (visit http://localhost:4567 to see the result)
Does this work? I ran ruby indexer.rb first. Then when I ran index.rb the following threw an error:
The error message was:
Tire::Search::SearchRequestFailed at /
500 : {"error":"SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[DuHC-F8lTEyBduM4jTkuvw][files][0]: SearchParseException[[files][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"query_string":{"query":"content:"}}}]]]; nested: QueryParsingException[[files] Failed to parse query [content:]]; nested: ParseException[Cannot parse 'content:': Encountered "" at line 1, column 8.\nWas expecting one of:\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ]; nested: ParseException[Encountered "" at line 1, column 8.\nWas expecting one of:\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ]; }{[DuHC-F8lTEyBduM4jTkuvw][files][3]: SearchParseException[[files][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"query_string":{"query":"content:"}}}]]]; nested: QueryParsingException[[files] Failed to parse query [content:]]; nested: ParseException[Cannot parse 'content:': Encountered "" at line 1, column 8.\nWas expecting one of:\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ]; nested: ParseException[Encountered "" at line 1, column 8.\nWas expecting one of:\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ]; }]","status":500}