Skip to content

[FEATURE] Custom (user-defined) scoring, stemming, and query functions #1097

@mnunberg1

Description

@mnunberg1

The problem/use-case that the feature addresses

Custom use cases where built-in scoring and stemming isn't sufficient. This is already present in Redis Search

Description of the feature

RS allows passing an EXTLOAD parameter with a dynamic object that defines several functions per a specific ABI. These functions provide ways for users to use custom or proprietary algorithms which would otherwise be inaccessible to them.

void MyQueryExpander(RSQueryExpanderCtx *ctx, RSToken *token) {
    ...
}

double MyScoringFunction(RSScoringFunctionCtx *ctx, RSIndexResult *res,
                                    RSDocumentMetadata *dmd, double minScore);
....

  if (ctx->RegisterScoringFunction("my_scorer", MyCustomScorer, NULL, NULL) == REDISEARCH_ERR) {
    return REDISEARCH_ERR;
  }

  /* Register a query expander  */
  if (ctx->RegisterQueryExpander("my_expander", MyExpander, NULL, NULL) ==
      REDISEARCH_ERR) {
    return REDISEARCH_ERR;
  }

  return REDISEARCH_OK;

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions