I include a bash script that recreates the situation.

#!/bin/sh

curl -XDELETE "http://localhost:9200/test";
curl -XPUT "http://localhost:9200/test";

echo

curl -XPUT "http://localhost:9200/test/foo/_mapping"; -d '{
    "foo" : { 
        "properties" : {
            "id": {
                "type" : "multi_field",
                "path": "full",
                "fields" : {
                    "foo_id_in_another_field" : {"type" : "long", 
include_in_all:false },
                "id" : {"type" : "long"}
                   }
        }
    }
    }
}'

echo

#foo is a basically a duplicate of the foo document to support search use cases
curl -XPUT "http://localhost:9200/test/bar/_mapping"; -d '{
    "bar" : {
        "properties" : {
            "id": {
                "type" : "multi_field",
                "path": "full",
                "fields" : {
                    "bar_id_in_another_field" : {"type" : "long", 
include_in_all:false },
                    "id" : {"type" : "long"}
                   }
                },
        "foo": {
            "properties": {
                "id": {
                    "type" : "multi_field",
                    "path": "full",
                    "fields" : {
                        "foo_id_in_another_field" : {"type" : "long", 
include_in_all:false },
                        "id" : {"type" : "long"}
                    }
                }
            }
        }
        }
    }
}'

echo

curl -XPUT "http://localhost:9200/test/foo/1?refresh=true"; -d '{
    "foo": {
                "id": 1
    }
}'

echo

#failure case appears even when not including the following JSON
# "bar": {
#   "id": 2,
#   "foo": {
#     "id": 3
#   }
# }
curl -XPUT "http://localhost:9200/test/bar/2?refresh=true"; -d '{
    "bar": {
        "id": 2
    }
}'

echo

#expect two results, get one (FAIL)
curl -XPOST "http://localhost:9200/test/foo,bar/_search?pretty=true"; -d '{
  "size": 10,
  "query": {
    "query_string": {
      "query": "foo.id:1 OR bar.id:2"
    }
  }
}'

echo

#except one result, get one (PASS)
curl -XPOST "http://localhost:9200/test/bar/_search?pretty=true"; -d '{
  "size": 10,
  "query": {
    "query_string": {
      "query": "foo.id:1 OR bar.id:2"
    }
  }
}'

echo

#expect one result, get one result (PASS)
curl -XPOST "http://localhost:9200/test/foo/_search?pretty=true"; -d '{
  "size": 10,
  "query": {
    "query_string": {
      "query": "foo.id:1 OR bar.id:2"
    }
  }
}'

echo

#expect two results, get tow results (PASS)
curl -XPOST "http://localhost:9200/test/_search?pretty=true"; -d '{
  "size": 10,
  "query": {
    "query_string": {
      "query": "foo.id:1 OR bar.id:2"
    }
  }
}'

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/1d8f1ea8-db1b-425c-b6ee-153f5f369f43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to