*Tweet Index definition : *

"tweet": {

        "tweet": {

            "index": {

                "number_of_shards": 2,

                "number_of_replicas": 1

            }

        },

        "mappings": {

            "blog": {

                "_all": {

                    "enabled": False

                },

                "dynamic": False

            }

        }

    }

 

*Tweet data insertion :*

curl -XPOST "http://localhost:9200/tweet/blog/"; -d'

{

    "id" : "ID1",

    "user" : "User1",

    "title" : "tweet1"

}'

curl -XPOST "http://localhost:9200/tweet/blog/"; -d'

{

    "id" : "ID2",

    "user" : "User2",

    "title" : "tweet2"

}'

 

*Read all data :*

curl -XGET "http://localhost:9200/tweet/blog/_search";

{

    took: 1

    timed_out: false

    _shards: {

        total: 2

        successful: 2

        failed: 0

    }

    hits: {

        total: 2

        max_score: 1

        hits: [

            {

                _index: tweet

                _type: blog

                _id: 1

                _score: 1

                _source: {

                        id : ID1,

                        user : User1,

                        title : tweet1

                }

            },

            {

                _index: tweet

                _type: blog

                _id: 2

                _score: 1

                _source: {

                        id : ID2,

                        user : User2,

                        title : tweet2

                }

            }

}

 

*Now I wish to fetch the document for User2*

 Based on Link 1 and 2, I have tried the following ways, however all in 
vein –

*Option 1:*

curl -XPOST "http://localhost:9200/tweet/blog/_search"; -d'

{

    "query" : {

        "term" : { "user" : "User2" }

    }

}'

 

*Option 2:*

     curl -XGET "http://localhost:9200/tweet/blog/_search?q=user:User2";

 

*Option 3:*

     curl -XGET "http://localhost:9200/tweet/blog/_search?source={user:User2}";

 

*Option 4:*

     curl -XGET 
"http://localhost:9200/tweet/blog/_search?_source={‘user’:’User2’}";

 

Link 1: 
http://okfnlabs.org/blog/2013/07/01/elasticsearch-query-tutorial.html#basic-queries-using-only-the-query-string

Link 2: 
http://blog.florian-hopf.de/2013/08/getting-started-with-elasticsearch-part.html

 

Do you recommend a suitable solution to this problem? 


-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/7ffecb9a-14f9-4cbe-beef-8227937f4168%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to