How to use the richie.apps.search.utils.indexers.slice_string_for_completion function in richie

To help you get started, we’ve selected a few richie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openfun / richie / tests / apps / search / test_autocomplete_organizations.py View on Github external
"fr": "Université de Paris 18",
                },
            },
            {
                "complete": {
                    "en": slice_string_for_completion("School of bikeshedding"),
                    "fr": slice_string_for_completion("École d'abri-vélo"),
                },
                "id": "34",
                "path": "000001",
                "title": {"en": "School of bikeshedding", "fr": "École d'abri-vélo"},
            },
            {
                "complete": {
                    "en": slice_string_for_completion("University of Paris 19"),
                    "fr": slice_string_for_completion("Université de Paris 19"),
                },
                "id": "52",
                "path": "000002",
                "title": {
                    "en": "University of Paris 19",
                    "fr": "Université de Paris 19",
                },
            },
        ]

        indices_client = IndicesClient(client=ES_CLIENT)
        # Delete any existing indices so we get a clean slate
        indices_client.delete(index="_all")
        # Create an index we'll use to test the ES features
        indices_client.create(index=ORGANIZATIONS_INDEX)
github openfun / richie / tests / apps / search / test_autocomplete_persons.py View on Github external
def execute_query(self, querystring="", **extra):
        """
        Not a test.
        Prepare the ElasticSearch index and execute the query in it.
        """

        persons = [
            {
                "complete": {"en": slice_string_for_completion("Éponine Thénardier")},
                "id": "25",
                "title": {"en": "Éponine Thénardier"},
            },
            {
                "complete": {
                    "en": slice_string_for_completion("Monseigneur Bienvenu Myriel")
                },
                "id": "34",
                "title": {"en": "Monseigneur Bienvenu Myriel"},
            },
            {
                "complete": {"en": slice_string_for_completion("Fantine")},
                "id": "52",
                "title": {"en": "Fantine"},
            },
        ]
github openfun / richie / tests / apps / search / test_autocomplete_organizations.py View on Github external
"en": "University of Paris 18",
                    "fr": "Université de Paris 18",
                },
            },
            {
                "complete": {
                    "en": slice_string_for_completion("School of bikeshedding"),
                    "fr": slice_string_for_completion("École d'abri-vélo"),
                },
                "id": "34",
                "path": "000001",
                "title": {"en": "School of bikeshedding", "fr": "École d'abri-vélo"},
            },
            {
                "complete": {
                    "en": slice_string_for_completion("University of Paris 19"),
                    "fr": slice_string_for_completion("Université de Paris 19"),
                },
                "id": "52",
                "path": "000002",
                "title": {
                    "en": "University of Paris 19",
                    "fr": "Université de Paris 19",
                },
            },
        ]

        indices_client = IndicesClient(client=ES_CLIENT)
        # Delete any existing indices so we get a clean slate
        indices_client.delete(index="_all")
        # Create an index we'll use to test the ES features
        indices_client.create(index=ORGANIZATIONS_INDEX)
github openfun / richie / tests / apps / search / test_autocomplete_organizations.py View on Github external
{
                "complete": {
                    "en": slice_string_for_completion("University of Paris 18"),
                    "fr": slice_string_for_completion("Université de Paris 18"),
                },
                "id": "25",
                "path": "000000",
                "title": {
                    "en": "University of Paris 18",
                    "fr": "Université de Paris 18",
                },
            },
            {
                "complete": {
                    "en": slice_string_for_completion("School of bikeshedding"),
                    "fr": slice_string_for_completion("École d'abri-vélo"),
                },
                "id": "34",
                "path": "000001",
                "title": {"en": "School of bikeshedding", "fr": "École d'abri-vélo"},
            },
            {
                "complete": {
                    "en": slice_string_for_completion("University of Paris 19"),
                    "fr": slice_string_for_completion("Université de Paris 19"),
                },
                "id": "52",
                "path": "000002",
                "title": {
                    "en": "University of Paris 19",
                    "fr": "Université de Paris 19",
                },
github openfun / richie / tests / apps / search / test_autocomplete_categories.py View on Github external
{
                "complete": {
                    "en": slice_string_for_completion("Elegiac bikeshedding"),
                    "fr": slice_string_for_completion("Élégie de l'abri à vélos"),
                },
                "id": "51",
                "kind": "subjects",
                "path": "001002",
                "title": {
                    "en": "Elegiac bikeshedding",
                    "fr": "Élégie de l'abri à vélos",
                },
            },
            {
                "complete": {
                    "en": slice_string_for_completion("Electric Decoys"),
                    "fr": slice_string_for_completion("Leurres électriques"),
                },
                "id": "44",
                "kind": "not_subjects",
                "path": "001003",
                "title": {"en": "Electric Decoys", "fr": "Leurres électriques"},
            },
        ]

        indices_client = IndicesClient(client=ES_CLIENT)
        # Delete any existing indices so we get a clean slate
        indices_client.delete(index="_all")
        # Create an index we'll use to test the ES features
        indices_client.create(index=CATEGORIES_INDEX)

        # The index needs to be closed before we set an analyzer
github openfun / richie / tests / apps / search / test_autocomplete_courses.py View on Github external
def execute_query(self, querystring="", **extra):
        """
        Not a test.
        Prepare the ElasticSearch index and execute the query in it.
        """

        courses = [
            {
                "complete": {
                    "en": slice_string_for_completion(
                        "Artificial intelligence for mushroom picking"
                    ),
                    "fr": slice_string_for_completion(
                        "Intelligence artificielle pour la cueillette de chàmpiñons"
                    ),
                },
                "course_runs": [],
                "id": "24",
                "path": "001000",
                "title": {
                    "en": "Artificial intelligence for mushroom picking",
                    "fr": "Intelligence artificielle pour la cueillette de chàmpiñons",
                },
            },
            {
                "complete": {
github openfun / richie / tests / apps / search / test_autocomplete_courses.py View on Github external
),
                },
                "course_runs": [],
                "id": "24",
                "path": "001000",
                "title": {
                    "en": "Artificial intelligence for mushroom picking",
                    "fr": "Intelligence artificielle pour la cueillette de chàmpiñons",
                },
            },
            {
                "complete": {
                    "en": slice_string_for_completion(
                        "Kung-fu moves for cloud infrastructure security"
                    ),
                    "fr": slice_string_for_completion(
                        "Protéger ses serveurs par la pratique des arts martiaux"
                    ),
                },
                "course_runs": [],
                "id": "33",
                "path": "001001",
                "title": {
                    "en": "Kung-fu moves for cloud infrastructure security",
                    "fr": "Prôtéger ses serveurs par la pratique des arts martiaux",
                },
            },
            {
                "complete": {
                    "en": slice_string_for_completion(
                        "Securing funding through token sales"
                    ),
github openfun / richie / tests / apps / search / test_autocomplete_organizations.py View on Github external
def execute_query(self, querystring="", **extra):
        """
        Not a test.
        Prepare the ElasticSearch index and execute the query in it.
        """

        organizations = [
            {
                "complete": {
                    "en": slice_string_for_completion("University of Paris 18"),
                    "fr": slice_string_for_completion("Université de Paris 18"),
                },
                "id": "25",
                "path": "000000",
                "title": {
                    "en": "University of Paris 18",
                    "fr": "Université de Paris 18",
                },
            },
            {
                "complete": {
                    "en": slice_string_for_completion("School of bikeshedding"),
                    "fr": slice_string_for_completion("École d'abri-vélo"),
                },
                "id": "34",
                "path": "000001",
github openfun / richie / tests / apps / search / test_autocomplete_categories.py View on Github external
},
            },
            {
                "complete": {
                    "en": slice_string_for_completion("Ocean biking"),
                    "fr": slice_string_for_completion("Cyclisme océanique"),
                },
                "id": "33",
                "kind": "subjects",
                "path": "001001",
                "title": {"en": "Ocean biking", "fr": "Cyclisme océanique"},
            },
            {
                "complete": {
                    "en": slice_string_for_completion("Elegiac bikeshedding"),
                    "fr": slice_string_for_completion("Élégie de l'abri à vélos"),
                },
                "id": "51",
                "kind": "subjects",
                "path": "001002",
                "title": {
                    "en": "Elegiac bikeshedding",
                    "fr": "Élégie de l'abri à vélos",
                },
            },
            {
                "complete": {
                    "en": slice_string_for_completion("Electric Decoys"),
                    "fr": slice_string_for_completion("Leurres électriques"),
                },
                "id": "44",
                "kind": "not_subjects",