Filtered query question

Ok, now that I finally have some stuff working I'm trying to figure
out why my filtered query is returning 0 records.

Here's my query:

{"query": {
"filtered" : {
"query_string" : {
"fields": ["description", "title"],
"query" : "Understanding"
},
"filter" : {
"term" : {
"docType" : "Event"
}
}
}
}
}

If I remove the filter portion it returns the records (who have the
docType fieild and the appropriate value of "Event").

Originally I didn't have the doctype in my mapping so I added it, but
it didn't help :/.

Any ideas? Been searching but don't see a lot of examples on filtered
queries on the web.

Thanks in advance.

-warner

Can you give the json output of one of the documents you expect to be
returned for this query? What is the exact value of the "docType" field for
that document?
Also, how is that field analyzed? Could it be that it has a
StandardAnalyzer and is lowercased ("event")?

Anne

On Tue, Jun 12, 2012 at 4:48 AM, Warner Onstine warnero@gmail.com wrote:

Ok, now that I finally have some stuff working I'm trying to figure
out why my filtered query is returning 0 records.

Here's my query:

{"query": {
"filtered" : {
"query_string" : {
"fields": ["description", "title"],
"query" : "Understanding"
},
"filter" : {
"term" : {
"docType" : "Event"
}
}
}
}
}

If I remove the filter portion it returns the records (who have the
docType fieild and the appropriate value of "Event").

Originally I didn't have the doctype in my mapping so I added it, but
it didn't help :/.

Any ideas? Been searching but don't see a lot of examples on filtered
queries on the web.

Thanks in advance.

-warner

--
Anne Veling
BeyondTrees.com
+31 6 50 969 170
@anneveling

        "filter" : {
            "term" : {
                "docType" : "Event"
            }
        }
    }
}

}

If I remove the filter portion it returns the records (who have the
docType fieild and the appropriate value of "Event").

You're using a term query which means "find exactly 'Event'", but I bet
you haven't mapped your docType field yourself, which means it is
default to be "analyzed" which means that, what is stored, is actually
'event', not 'Event'.

Set the mapping for that field to
{ type: "string", index: "not_analyzed"}

c

Originally I didn't have the doctype in my mapping so I added it, but
it didn't help :/.

Any ideas? Been searching but don't see a lot of examples on filtered
queries on the web.

Thanks in advance.

-warner

Here's a snippet:

{"took":17,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":0,"max_score":null,"hits":}}Holden:logs
warnero$ curl -XGET 'localhost:9200/syncrswim/_search' -d
'{"query":{"filtere"query_string" : {"query" : "Teach","fields" : [
"title", "description" ]}}}}}'
{"took":37,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":0.18167211,"hits":[{"_index":"syncrswim","_type":"syncrswim","_id":"3283712673","_score":0.18167211,
"_source" : {"tags":["meditation"],
"docType":"Event",
"lastUpdated":"2012-05-13 14:30:36",

So, you can see docType is uppercase Event. I'm just using a default
analyzer (no customizations).

-warner

On Tue, Jun 12, 2012 at 1:15 AM, Anne Veling anne@beyondtrees.com wrote:

Can you give the json output of one of the documents you expect to be
returned for this query? What is the exact value of the "docType" field for
that document?
Also, how is that field analyzed? Could it be that it has a StandardAnalyzer
and is lowercased ("event")?

Anne

On Tue, Jun 12, 2012 at 4:48 AM, Warner Onstine warnero@gmail.com wrote:

Ok, now that I finally have some stuff working I'm trying to figure
out why my filtered query is returning 0 records.

Here's my query:

{"query": {
"filtered" : {
"query_string" : {
"fields": ["description", "title"],
"query" : "Understanding"
},
"filter" : {
"term" : {
"docType" : "Event"
}
}
}
}
}

If I remove the filter portion it returns the records (who have the
docType fieild and the appropriate value of "Event").

Originally I didn't have the doctype in my mapping so I added it, but
it didn't help :/.

Any ideas? Been searching but don't see a lot of examples on filtered
queries on the web.

Thanks in advance.

-warner

--
Anne Veling
BeyondTrees.com
+31 6 50 969 170
@anneveling

If you're using the default analyzer, it is mapped to "event".
You could verify that by changing the filter query to "event" and see if
you get the document back.

Could you try changing the analyzer of the docType field to "not_analyzed"?

Anne

On Tue, Jun 12, 2012 at 3:44 PM, Warner Onstine warnero@gmail.com wrote:

Here's a snippet:

{"took":17,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":0,"max_score":null,"hits":}}Holden:logs
warnero$ curl -XGET 'localhost:9200/syncrswim/_search' -d
'{"query":{"filtere"query_string" : {"query" : "Teach","fields" : [
"title", "description" ]}}}}}'

{"took":37,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":0.18167211,"hits":[{"_index":"syncrswim","_type":"syncrswim","_id":"3283712673","_score":0.18167211,
"_source" : {"tags":["meditation"],
"docType":"Event",
"lastUpdated":"2012-05-13 14:30:36",

So, you can see docType is uppercase Event. I'm just using a default
analyzer (no customizations).

-warner

On Tue, Jun 12, 2012 at 1:15 AM, Anne Veling anne@beyondtrees.com wrote:

Can you give the json output of one of the documents you expect to be
returned for this query? What is the exact value of the "docType" field
for
that document?
Also, how is that field analyzed? Could it be that it has a
StandardAnalyzer
and is lowercased ("event")?

Anne

On Tue, Jun 12, 2012 at 4:48 AM, Warner Onstine warnero@gmail.com
wrote:

Ok, now that I finally have some stuff working I'm trying to figure
out why my filtered query is returning 0 records.

Here's my query:

{"query": {
"filtered" : {
"query_string" : {
"fields": ["description", "title"],
"query" : "Understanding"
},
"filter" : {
"term" : {
"docType" : "Event"
}
}
}
}
}

If I remove the filter portion it returns the records (who have the
docType fieild and the appropriate value of "Event").

Originally I didn't have the doctype in my mapping so I added it, but
it didn't help :/.

Any ideas? Been searching but don't see a lot of examples on filtered
queries on the web.

Thanks in advance.

-warner

--
Anne Veling
BeyondTrees.com
+31 6 50 969 170
@anneveling

--
Anne Veling
BeyondTrees.com
+31 6 50 969 170
@anneveling

Moving it to lowercase did the trick thank you!

-warner

On Tue, Jun 12, 2012 at 12:11 PM, Anne Veling anne@beyondtrees.com wrote:

If you're using the default analyzer, it is mapped to "event".
You could verify that by changing the filter query to "event" and see if you
get the document back.

Could you try changing the analyzer of the docType field to "not_analyzed"?

Anne

On Tue, Jun 12, 2012 at 3:44 PM, Warner Onstine warnero@gmail.com wrote:

Here's a snippet:

{"took":17,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":0,"max_score":null,"hits":}}Holden:logs
warnero$ curl -XGET 'localhost:9200/syncrswim/_search' -d
'{"query":{"filtere"query_string" : {"query" : "Teach","fields" : [
"title", "description" ]}}}}}'

{"took":37,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":0.18167211,"hits":[{"_index":"syncrswim","_type":"syncrswim","_id":"3283712673","_score":0.18167211,
"_source" : {"tags":["meditation"],
"docType":"Event",
"lastUpdated":"2012-05-13 14:30:36",

So, you can see docType is uppercase Event. I'm just using a default
analyzer (no customizations).

-warner

On Tue, Jun 12, 2012 at 1:15 AM, Anne Veling anne@beyondtrees.com wrote:

Can you give the json output of one of the documents you expect to be
returned for this query? What is the exact value of the "docType" field
for
that document?
Also, how is that field analyzed? Could it be that it has a
StandardAnalyzer
and is lowercased ("event")?

Anne

On Tue, Jun 12, 2012 at 4:48 AM, Warner Onstine warnero@gmail.com
wrote:

Ok, now that I finally have some stuff working I'm trying to figure
out why my filtered query is returning 0 records.

Here's my query:

{"query": {
"filtered" : {
"query_string" : {
"fields": ["description", "title"],
"query" : "Understanding"
},
"filter" : {
"term" : {
"docType" : "Event"
}
}
}
}
}

If I remove the filter portion it returns the records (who have the
docType fieild and the appropriate value of "Event").

Originally I didn't have the doctype in my mapping so I added it, but
it didn't help :/.

Any ideas? Been searching but don't see a lot of examples on filtered
queries on the web.

Thanks in advance.

-warner

--
Anne Veling
BeyondTrees.com
+31 6 50 969 170
@anneveling

--
Anne Veling
BeyondTrees.com
+31 6 50 969 170
@anneveling