JanusGraph / JanusGraph/janusgraph

Case insensitive textRegex predicate option

Open
#3,878 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/index
Dominant language
Java
Stars
5.8k
Forks
1.2k
Avg merge
13h 53m
Merged PRs (30d)
6

Description

**Describe the feature:**
Currently textRegex applies a case sensitive matching by default. In my particular use case I'm using Elasticsearch as my mixed index backend, and it is case sensitive [by default](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html#term-field-params), but the parameter `case_insensitive` was reportedly added as of `7.10.0`

It'd be nice to expose the case insensitive option. Otherwise the workaround alternative for a hypothetical case insensitive search is to modify the regex with per index casing. For example for a case insensitive search for `foo` doing: `textRegex(".*[Ff][Oo][Oo].*")`.

I suppose another option would be to do a `textContains` for ideally the most unique contiguous word of my regex (obviously just `foo` in the aforementioned hypothetical) and then use a Java lambda that invokes the Java regex engine as a filter step. Only if the search space is narrowed sufficiently since that would be in-memory filtering obviously.

**Describe a specific use case for the feature:**
I have a String property indexed as a String mapped field (as in `Mapping.STRING.asParameter()` to be clear) to my ES backend that I'd like to do a case insensitive "ends with" regex akin to `textRegex(.*foo)`. Text mapping (as in `Mapping.TEXT.asParameter()`) would operate with case insensitivity but this property has non-alphanumeric characters which will cause the string to split preventing during tokenizing which will prevent being able to match "end of the string" in the manner I'm hoping to do, AFAIK.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the textRegex predicate into the Elasticsearch mixed-index query generation and check how Elasticsearch 7.10.0's case_insensitive parameter can be represented. The feature is done when a case-insensitive textRegex option works for String-mapped fields, including the described case-insensitive ends-with use case, without requiring regex character expansion.

Written by the indexing model from the issue text.

Assessment

Tech stack
elasticsearch, java
Domain
databases, search
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.