Ejemplo n.º 1
0
 def get_es_context(self, **kwargs):
     return {
         "index": utils.get_elasticsearch_index(),
         "doc_type": utils.get_elasticsearch_type(),
         "size": 0,
         "body": {
             "query": {
                 "constant_score": {
                     "filter": {
                         "term": {
                             "is_banned": 1
                         }
                     }
                 }
             },
             "aggs": {
                 "domains": {
                     "terms": {
                         "field": "domain",
                         "size": 1000
                     }
                 }
             }
         },
         "_source_include":
         ["title", "url", "meta", "updated_on", "domain"]
     }
Ejemplo n.º 2
0
 def get_es_context(self, **kwargs):
     return {
         "index": utils.get_elasticsearch_index(),
         "doc_type": utils.get_elasticsearch_type(),
         "size": 0,
         "body": {
             "aggs" : {
                 "domains" : {
                     "terms" : {"field" : "domain",
                                "size": 1000}
                 }
             }
         },
         "_source_include": ["title", "url", "meta", "updated_on", "domain"]
     }
Ejemplo n.º 3
0
 def get_es_context(self, **kwargs):
     query = kwargs['q']
     return {
         "index": utils.get_elasticsearch_index(),
         "doc_type": utils.get_elasticsearch_type(),
         "body": {
             "query": {
                 "bool": {
                     "must": [{
                         "multi_match": {
                             "query":
                             query,
                             "type":
                             "most_fields",
                             "fields":
                             ["fancy", "fancy.stemmed", "fancy.shingles"],
                             "minimum_should_match":
                             "75%",
                             "cutoff_frequency":
                             0.01
                         }
                     }],
                     "must_not": [{
                         "exists": {
                             "field": "is_fake",
                             "field": "is_banned"
                         }
                     }]
                     # "filter": [
                     #     {
                     #         "missing": {
                     #             "field": "is_fake"
                     #         }
                     #     },
                     #     {
                     #         "missing": {
                     #             "field": "is_banned"
                     #         }
                     #     }
                     # ]
                 }
             },
             "aggregations": {
                 "domains": {
                     "terms": {
                         "size": 1000,
                         "field": "domain",
                         "order": {
                             "max_score": "desc"
                         }
                     },
                     "aggregations": {
                         "score": {
                             "top_hits": {
                                 "size":
                                 1,
                                 "sort": [{
                                     "authority": {
                                         "order": "desc",
                                         "missing": 0.0000000001
                                     }
                                 }, {
                                     "_score": {
                                         "order": "desc"
                                     }
                                 }],
                                 "_source": {
                                     "include": [
                                         "title", "url", "meta",
                                         "updated_on", "domain",
                                         "authority", "anchors"
                                     ]
                                 }
                             }
                         },
                         "max_score": {
                             "max": {
                                 "script": "_score"
                             }
                         }
                     }
                 }
             }
         },
         "size": 0
     }
Ejemplo n.º 4
0
    def get_es_context(self, **kwargs):
        query = kwargs['q']
        return {
            "index": utils.get_elasticsearch_index(),
            "doc_type": utils.get_elasticsearch_type(),
            "body": {
                "query": {
                    "bool": {
                        "must": [
                            {
                                "multi_match": {
                                    "query": query,
                                    "type":   "most_fields",
                                    "fields": [
                                        "fancy",
                                        "fancy.stemmed",
                                        "fancy.shingles"
                                    ],
                                    "minimum_should_match": "75%",
                                    "cutoff_frequency": 0.01
                                }
                            }
                        ],
                        "filter": [
                            {
                                "missing": {
                                    "field": "is_fake"
                                }
                            },
                            {
                                "missing": {
                                    "field": "is_banned"
                                }
                            }
                        ]
                    }

                },
                "aggregations" : {
                    "domains" : {
                        "terms" : {
                            "size" : 1000,
                            "field" : "domain",
                            "order": {"max_score": "desc"}
                        },
                        "aggregations": {
                            "score": {
                                "top_hits": {
                                    "size" : 1,
                                    "sort": [
                                        {
                                            "authority": {
                                                "order": "desc",
                                                "missing": 0.0000000001
                                            }
                                        },
                                        {
                                            "_score": {
                                                "order": "desc"
                                            }
                                        }
                                    ],
                                    "_source": {
                                        "include": ["title", "url", "meta",
                                                    "updated_on", "domain",
                                                    "authority", "anchors"]
                                    }
                                }
                            },
                            "max_score": {
                                "max": {
                                    "script": "_score"
                                }
                            }
                        }
                    }
                }
            },
            "size": 0
        }