Skip to content

feat(vectorstore): add kotlin filter expression DSL for vector store #2733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Ahoo-Wang
Copy link
Contributor

@Ahoo-Wang Ahoo-Wang commented Apr 14, 2025

  • Implement FilterExpressionDsl class for building complex filter expressions
  • Add support for various filter operations: and, or, eq, ne, gt, gte, lt, lte, in, nin ...
  • Implement logical operators: and, or, not
  • Add unit tests for filter expression DSL
  • Update project dependencies to include Kotlin stdlib

examples:

https://github.com/Ahoo-Wang/spring-ai/blob/FilterExpressionDsl/spring-ai-vector-store/src/test/kotlin/org/springframework/ai/vectorstore/filter/FilterExpressionDslTest.kt

	@Test
	fun complexDsl() {
		val filterExpression = filterExpression {
			"field1".eq("value1")
			and {
				"field2".ne("value2")
				"field3".gt(3)
				"field4".gte(4)
				or {
					"field5".lt(5)
					"field6".lte(6)
				}
			}
		}

		assertThat(filterExpression).isEqualTo(
			builder.and(
				builder.eq("field1", "value1"),
				builder.and(
					builder.and(
						builder.and(
							builder.ne("field2", "value2"),
							builder.gt("field3", 3),
						),
						builder.gte("field4", 4)
					),
					builder.or(
						builder.lt("field5", 5),
						builder.lte("field6", 6)
					)
				)
			).build()
		)
	}

- Implement FilterExpressionDsl class for building complex filter expressions
- Add support for various filter operations: eq, ne, gt, gte, lt, lte, in, nin
- Implement logical operators: and, or, not
- Add unit tests for filter expression DSL
- Update project dependencies to include Kotlin stdlib

Signed-off-by: Ahoo Wang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant