Pages

Monday, December 17, 2012

Highlighting search results with the query term in ElasticSearch


 curl -XGET 'http://localhost:9200/document/_search?pretty=true' -d '{
    "query" : { "query_string" : { "query": "assistance in voting" }},
    "highlight" : {
        "fields" : {
            "text" : {}
        }
    }
}'


Monday, November 26, 2012

MyFitnessPal vs Livestrong My Plate

Tried both apps today, My Plate might have a better user interface but overall I like MyFitnessPal, better database and ease of use.

Highlighting search results with the query term in ElasticSearch


Highlighting search results with the query term in ElasticSearch:

curl -XGET 'http://localhost:9200/document/_search?pretty=true' -d '{
    "query" : { "term" : { "title": "mobile" }},
    "highlight" : {
        "fields" : {
            "text" : {}
        }
    }
}'

Wednesday, November 21, 2012

Deleting documents from your index Apache Solr


How can I delete all documents from my index?

Use the "match all docs" query in a delete by query command: <delete><query>*:*</query></delete>
You must also commit after running the delete so, to empty the index, run the following two commands:
curl http://localhost:8983/solr/update --data '<delete><query>*:*</query></delete>' -H 'Content-type:text/xml; charset=utf-8'  
curl http://localhost:8983/solr/update --data '<commit/>' -H 'Content-type:text/xml; charset=utf-8'
Another strategy would be to add two bookmarks in your browser:
http://localhost:8983/solr/update?stream.body=<delete><query>*:*</query></delete>
http://localhost:8983/solr/update?stream.body=<commit/>
And use those as you're developing to clear out the index as necessary.

for loop in unix

for (( i = 1 ; i <= 10000; i++ )); do java -jar post.jar $i.xml; done