Topic on Help talk:CirrusSearch

-incategory don't work

10
Nicolas senechal (talkcontribs)

I try to -incategory:"Actif" and I have a result of an include. So I try with ! and he doesn't work (-! and !- (is equal with -)). I try to include Actif with incategory:"Actif" and he doesn't work.

It's not normal... how can fix this?

Any help is apprised.

DCausse (WMF) (talkcontribs)

The syntax you are using is correct and should work:

-incategory:"Cartographie"

is searching for pages that are not directly under the Cartographie category.


It might be that you are expecting incategory to find articles belonging to the tree of subcategories?

This is not the case, incategory is limited to direct relationships.

For finding articles in a category and the subcategories of this category you must use the deepcat keyword: deepcat:"Cartographie".


This keyword is available on WMF wikis.

Nicolas senechal (talkcontribs)

Thank you @DCausse (WMF), but it's still doesn't work.

Actif is the directely liked.

And I try again with deepcat the same, but doesn't work with just deepcat.

DCausse (WMF) (talkcontribs)

If you are using a publicly accessible wiki could you provide the link to it so that we can try to have a closer look?

If you are using your own private wiki could you double check that CirrusSearch is properly installed, to do this I generally append &cirrusDumpQuery to the URL bar on the search results page.

This is how it looks like on the french wikipedia:

https://fr.wikipedia.org/w/index.php?search=-incategory%3ACartographie&title=Sp%C3%A9cial%3ARecherche&ns0=1&cirrusDumpQuery


This should display the JSON document sent to elasticsearch and we might be able to detect what is wrong in your setup, esp. if the match query on the category.lowercase_keyword field is wrapped inside a must_not block or not.

The deepcat keyword requires a graph engine to be installed and setup, this most probably explains why it does not work out of the box.

Nicolas senechal (talkcontribs)
Nicolas senechal (talkcontribs)

OK - after checking my install

I have 1 question :

I only have to have the elastica extension for Wikipedia, and the library cURL in order to running circusSearch?

If no, so how can I download for xampp on windows elastica librairie for php?

Nicolas senechal (talkcontribs)

After some time I retry to download elasticaSearch, now it work, incategory don't realy work (so for me: !incategory: and -incategory: to include, I don't have exclude, the oprator like OR, AND, NOT don't work).

So in order to run ElasticSearch I have to do a command in the cmd on windows, but I need to have a cmd run constantly. I shear on the internet and I find the commend START \B .So now I have elasticSearsh who run in a hidden cmd. To stop it I just have to close my common cmd.


so here is the result with &cirrusDumpQuery for !incategory:"Actif" -incategory:"Sql"

{

    "__main__": {

        "description": "full_text search for '!incategory:\"Actif\" -incategory:\"Sql\"'",

        "path": "test\/page\/_search",

        "params": {

            "timeout": "20s",

            "search_type": "dfs_query_then_fetch"

        },

        "query": {

            "_source": [

                "namespace",

                "title",

                "namespace_text",

                "wiki",

                "redirect.*",

                "timestamp",

                "text_bytes"

            ],

            "stored_fields": [

                "text.word_count"

            ],

            "query": {

                "bool": {

                    "minimum_should_match": 1,

                    "should": [

                        {

                            "query_string": {

                                "query": "!incategory\\: (all.plain:\"Actif\"~0^1)",

                                "fields": [

                                    "all.plain^1",

                                    "all^0.5"

                                ],

                                "phrase_slop": 0,

                                "default_operator": "AND",

                                "allow_leading_wildcard": true,

                                "fuzzy_prefix_length": 2,

                                "rewrite": "top_terms_boost_1024"

                            }

                        },

                        {

                            "multi_match": {

                                "fields": [

                                    "all_near_match^2",

                                    "all_near_match.asciifolding^1.5"

                                ],

                                "query": "!incategory:"

                            }

                        }

                    ],

                    "filter": [

                        {

                            "bool": {

                                "must": [

                                    {

                                        "terms": {

                                            "namespace": [

                                                0,

                                                4,

                                                6,

                                                14

                                            ]

                                        }

                                    }

                                ],

                                "must_not": [

                                    {

                                        "bool": {

                                            "should": [

                                                {

                                                    "match": {

                                                        "category.lowercase_keyword": {

                                                            "query": "Sql"

                                                        }

                                                    }

                                                }

                                            ]

                                        }

                                    }

                                ]

                            }

                        }

                    ]

                }

            },

            "highlight": {

                "pre_tags": [

                    "\ue000"

                ],

                "post_tags": [

                    "\ue001"

                ],

                "fields": {

                    "title": {

                        "type": "fvh",

                        "number_of_fragments": 0,

                        "order": "score",

                        "matched_fields": [

                            "title",

                            "title.plain"

                        ]

                    },

                    "redirect.title": {

                        "type": "fvh",

                        "number_of_fragments": 1,

                        "order": "score",

                        "fragment_size": 10000,

                        "matched_fields": [

                            "redirect.title",

                            "redirect.title.plain"

                        ]

                    },

                    "category": {

                        "type": "fvh",

                        "number_of_fragments": 1,

                        "order": "score",

                        "fragment_size": 10000,

                        "matched_fields": [

                            "category",

                            "category.plain"

                        ]

                    },

                    "heading": {

                        "type": "fvh",

                        "number_of_fragments": 1,

                        "order": "score",

                        "fragment_size": 10000,

                        "matched_fields": [

                            "heading",

                            "heading.plain"

                        ]

                    },

                    "text": {

                        "type": "fvh",

                        "number_of_fragments": 1,

                        "order": "score",

                        "fragment_size": 150,

                        "no_match_size": 150,

                        "matched_fields": [

                            "text",

                            "text.plain"

                        ]

                    },

                    "auxiliary_text": {

                        "type": "fvh",

                        "number_of_fragments": 1,

                        "order": "score",

                        "fragment_size": 150,

                        "matched_fields": [

                            "auxiliary_text",

                            "auxiliary_text.plain"

                        ]

                    },

                    "file_text": {

                        "type": "fvh",

                        "number_of_fragments": 1,

                        "order": "score",

                        "fragment_size": 150,

                        "matched_fields": [

                            "file_text",

                            "file_text.plain"

                        ]

                    }

                },

                "highlight_query": {

                    "query_string": {

                        "query": "!incategory\\: (title.plain:\"Actif\"~0^20 OR redirect.title.plain:\"Actif\"~0^15 OR category.plain:\"Actif\"~0^8 OR heading.plain:\"Actif\"~0^5 OR opening_text.plain:\"Actif\"~0^3 OR text.plain:\"Actif\"~0^1 OR auxiliary_text.plain:\"Actif\"~0^0.5 OR file_text.plain:\"Actif\"~0^0.5)",

                        "fields": [

                            "title.plain^20",

                            "redirect.title.plain^15",

                            "category.plain^8",

                            "heading.plain^5",

                            "opening_text.plain^3",

                            "text.plain^1",

                            "auxiliary_text.plain^0.5",

                            "file_text.plain^0.5",

                            "title^10",

                            "redirect.title^7.5",

                            "category^4",

                            "heading^2.5",

                            "opening_text^1.5",

                            "text^0.5",

                            "auxiliary_text^0.25",

                            "file_text^0.25"

                        ],

                        "phrase_slop": 1,

                        "default_operator": "AND",

                        "allow_leading_wildcard": true,

                        "fuzzy_prefix_length": 2,

                        "rewrite": "top_terms_boost_1024"

                    }

                }

            },

            "stats": [

                "full_text",

                "full_text_querystring",

                "complex_query",

                "incategory",

                "query_string"

            ],

            "rescore": [

                {

                    "window_size": 8192,

                    "query": {

                        "query_weight": 1,

                        "rescore_query_weight": 1,

                        "score_mode": "multiply",

                        "rescore_query": {

                            "function_score": {

                                "functions": [

                                    {

                                        "field_value_factor": {

                                            "field": "incoming_links",

                                            "modifier": "log2p",

                                            "missing": 0

                                        }

                                    },

                                    {

                                        "weight": 0.1,

                                        "filter": {

                                            "terms": {

                                                "namespace": [

                                                    4

                                                ]

                                            }

                                        }

                                    },

                                    {

                                        "weight": 0.2,

                                        "filter": {

                                            "terms": {

                                                "namespace": [

                                                    6,

                                                    14

                                                ]

                                            }

                                        }

                                    }

                                ]

                            }

                        }

                    }

                }

            ],

            "size": 21

        },

        "options": {

            "timeout": "20s",

            "search_type": "dfs_query_then_fetch"

        }

    }

}

DCausse (WMF) (talkcontribs)

Hi,

the proper syntax is -incategory:Sql and the json output you pasted shows that it works since it has this section:

"must_not": [
    {
        "bool": {
            "should": [
                {
                    "match": {
                        "category.lowercase_keyword": {
                            "query": "Sql"
                        }
                    }
                }
            ]
        }
    }
]
Nicolas senechal (talkcontribs)

Thank you very much for your patience and your response!

But why does it work without quotes to exclude and work with quotes to include?

DCausse (WMF) (talkcontribs)

incategory:"sql" and incategory:sql should produce the same query.

Similarly, -incategory:"sql" and -incategory:sql should also produce the same query. If not please try to identify what differs from the cirrusDumpQuery output.

Reply to "-incategory don't work"