Oyelowo / surreal-orm

Powerful & expressive ORM/query-builder/static checker for raw queries/Fully Automated migration tooling , designed to offer an intuitive API, strict type-checking, novel features, & full specification support. It provides a fresh perspective in data management. Currently supports SurrealDB engine. RDMSs(PG, MYSQL etc) and others coming soon
93 stars 3 forks source link

Complete define index statement #30

Closed Oyelowo closed 1 year ago

Oyelowo commented 1 year ago

Support search analyzer in define statement

Example:

        let email = Field::new("email");

        let query = define_index("userEmailIndex")
            .on_table("user")
            .fields([email])
            .search_analyzer(
                search_analyzer("ascii")
                    .highlight()
                    .bm25(1.2, 0.75)
                    .doc_ids_order(1)
                    .doc_lengths_order(1)
                    .postings_order(1)
                    .terms_order(1),
            );

        assert_eq!(
            query.to_raw().build(),
            "DEFINE INDEX userEmailIndex ON TABLE user FIELDS email SEARCH ANALYZER ascii HIGHLIGHTS BM25 1.2f 0.75f DOC_IDS_ORDER 1 DOC_LENGTHS_ORDER 1 POSTINGS_ORDER 1 TERMS_ORDER 1;"
        );
        assert_eq!(query.fine_tune_params(),
        "DEFINE INDEX userEmailIndex ON TABLE $_param_00000001 FIELDS email SEARCH ANALYZER $_param_00000002 HIGHLIGHTS BM25 $_param_00000003 $_param_00000004 DOC_IDS_ORDER $_param_00000005 DOC_LENGTHS_ORDER $_param_00000006 POSTINGS_ORDER $_param_00000007 TERMS_ORDER $_param_00000008;"
        );
        assert_eq!(query.get_bindings().len(), 8);