Percolate Queries

Hello,

Following recommendation from one of you, I changed the approach to perform queries to percolate.

I've store each one of the named_queries and it returns me the results "more or less" in the way I need.

However, my app need filter those queries by dynamic params into the request and now with percolate I´m not able to get the results that I want.

Here's my mapping

{
  "template": "documents-en",
  "settings": {
    "index": {
      "number_of_shards": 5,
      "number_of_replicas": 0
    },
    "analysis": {
      "filter": {
        "english_stop": {
          "type":       "stop",
          "stopwords":  "_english_"
        },
        "english_keywords": {
          "type":       "keyword_marker",
          "keywords":   ["example"]
        },
        "english_stemmer": {
          "type":       "stemmer",
          "language":   "english"
        },
        "english_possessive_stemmer": {
          "type":       "stemmer",
          "language":   "possessive_english"
        }
      },
      "analyzer": {
        "rebuilt_english": {
          "tokenizer":  "standard",
          "filter": [
            "english_possessive_stemmer",
            "lowercase",
            "english_stop",
            "english_keywords",
            "english_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "document": {
      "properties": {
        "text": {
          "type": "text",
          "analyzer": "rebuilt_english"
        },
        "goal": {
          "type": "keyword"
        },
        "blocking": {
          "type": "boolean"
        },
        "country_code": {
          "type": "keyword",
          "null_value": "_null_"
        },
        "query": {
          "type": "percolator"
        }
      }
    }
  }
}

Here an example of each query stored

{
                "_index": "documents-en",
                "_type": "document",
                "_id": "aQxj-mcBOTQdqKhHFO56",
                "_score": 1,
                "_source": {
                    "size": 1,
                    "query": {
                        "bool": {
                            "must": {
                                "simple_query_string": {
                                    "query": "+\\\"\"Marlboro coupons\\\"\" ",
                                    "fields": [
                                        "text"
                                    ],
                                    "default_operator": "and",
                                    "_name": 157
                                }
                            }
                        }
                    },
                    "goal": 2,
                    "country_code": null,
                    "blocking": true
                }
            }

And here the request that I do to get results:

{
	"query": {
		"percolate": {
			"field": "query",
			"document": {
				"text": "We specialize baby for adoption birth call girl control pills  in all phones and tablet repairs iPhone 6 starting at just 25 bucks Same day repairs Low price keef Superior on catcher We will beat any in shirt Call firestick games :::   ::: Masa sandalye masa sandalye masa sandalye",
				"goal": 3,
				"blocking": true,
				"country_code": "TR"
			}
		}
	},
	"highlight": {
		"order": "none",
		"pre_tags": ["<span class=\"highlight\">"],
		"post_tags": ["<\/span>"],
		"fields": {
			"text": {
				"number_of_fragments": 0,
				"force_source": true
			}
		}
	}
}

The point here is I need to prioritize results where blocking: true and match with given country_code or null and given goal or 1.

Any ideas ?

Thanks in advance

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.