Query, but only in records having a specific category

Hi,

I'm new to elasticsearch, but already very impressed.

But actually I stuck with the following problem:
This is part of my mapping:

"mappings" : {
  "content" : {
    "properties" : {
      "contentid" : { "type" : "string", "index" : "not_analyzed", 

"store" : "yes" },
"title" : { "type" : "string", "boost" : "3", "store" : "yes" },
"categoryids" : {
"type" : "multi_field",
"fields" : {
"categoryids" : { "type" : "string", "index" :
"not_analyzed", "store" : "yes" },
"facet" : { "type" : "string", "index" : "not_analyzed" }
}
},
"summary" : { "type" : "string", "boost" : "3", "store" : "yes",
"index" : "analyzed", "analyzer" : "german" },
"body" : { "type" : "string", "index" : "analyzed", "analyzer" :
"german", "store" : "yes" },
"searchexclude" : { "type" : "byte", "store" : "yes",
"null_value" : "0" },
....

What I need is a fulltext search over several fields of my records (title,
summary, body, etc.).
This is my actual query that works fine:
GET _search
{
"query": {
"query_string": {
"query": "mySearchTerm"
}
}
,"highlight" : {
"fields" : {
"body" : {}
}
}
,"sort" : [
"_score",
{ "jahr" : {"order" : "desc"}}
]
,"fields" : ["summary","title","filename","categoryid"]
};

But now I want only records searched where searchexlude=0 and a specific
categoryid.

That's the point, where I stuck.
How can I do a fulltextsearch but only on specifix records?
What I read in the documentation is, that I need a filtered query, but I
always get bad requests. Also I read, that filtering means loosing the
score.

Any help apreciated.

Thanks,
Michi

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/75eb4771-3979-4ad8-9a29-563ae7f5c4af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Filtered query is the way to go.
Filters don't participate to the score does not mean that the query score is reset.

Have a look at http://www.elasticsearch.org/help to see how to send a full example to this list.

HTH

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 1 nov. 2014 à 15:22, Michael Hnat mhnat74@googlemail.com a écrit :

Hi,

I'm new to elasticsearch, but already very impressed.

But actually I stuck with the following problem:
This is part of my mapping:

"mappings" : {
  "content" : {
    "properties" : {
      "contentid" : { "type" : "string", "index" : "not_analyzed", "store" : "yes" },
      "title" : { "type" : "string", "boost" : "3", "store" : "yes" },
      "categoryids" : {
        "type" : "multi_field",
        "fields" : {
          "categoryids" : { "type" : "string", "index" : "not_analyzed", "store" : "yes" },
          "facet" : { "type" : "string", "index" : "not_analyzed" }
        }
      },
      "summary" : { "type" : "string", "boost" : "3", "store" : "yes", "index" : "analyzed", "analyzer" : "german" },
      "body" : { "type" : "string", "index" : "analyzed", "analyzer" : "german", "store" : "yes" },
      "searchexclude" : { "type" : "byte", "store" : "yes", "null_value" : "0" },

....

What I need is a fulltext search over several fields of my records (title, summary, body, etc.).
This is my actual query that works fine:
GET _search
{
"query": {
"query_string": {
"query": "mySearchTerm"
}
}
,"highlight" : {
"fields" : {
"body" : {}
}
}
,"sort" : [
"_score",
{ "jahr" : {"order" : "desc"}}
]
,"fields" : ["summary","title","filename","categoryid"]
};

But now I want only records searched where searchexlude=0 and a specific categoryid.

That's the point, where I stuck.
How can I do a fulltextsearch but only on specifix records?
What I read in the documentation is, that I need a filtered query, but I always get bad requests. Also I read, that filtering means loosing the score.

Any help apreciated.

Thanks,
Michi

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/75eb4771-3979-4ad8-9a29-563ae7f5c4af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/04257577-AC26-48F4-8849-4213E5B9B1F6%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.