From b5924328b8e38d9c14d2573ce45c2f1227a76f7e Mon Sep 17 00:00:00 2001 From: Marcin Lewandowski Date: Fri, 22 Mar 2024 14:29:27 +0100 Subject: [PATCH] Cannot query with where after moreLikeThis #409 --- .../Session/AbstractDocumentQuery.ts | 2 +- test/Ported/MoreLikeThis/MoreLikeThisTest.ts | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Documents/Session/AbstractDocumentQuery.ts b/src/Documents/Session/AbstractDocumentQuery.ts index f779833a0..20fe5e58a 100644 --- a/src/Documents/Session/AbstractDocumentQuery.ts +++ b/src/Documents/Session/AbstractDocumentQuery.ts @@ -393,7 +393,7 @@ export abstract class AbstractDocumentQuery> { @@ -258,6 +259,40 @@ describe("MoreLikeThisTests", function () { await assertMoreLikeThisHasMatchesFor("DataIndex", store, id); }); + it("can use whereEquals after moreLikeThis", async () => { + const key = "data/1-A"; + + { + const session = store.openSession(); + + await new DataIndex().execute(store); + + for (let i = 0; i < 3; i++) { + const data = new Data(); + data.body = "Body" + i; + data.whitespaceAnalyzerField = "test test"; + await session.store(data); + } + + await session.saveChanges(); + await testContext.waitForIndexing(store); + } + + { + const session = store.openSession(); + const query = session + .query({ indexName: "DataIndex" }) + .moreLikeThis(f => f.usingDocument(b => b.whereEquals("id()", key))) + .whereEquals("body", "Body2"); + + const list = await query.all(); + assertThat(query.toString()) + .isEqualTo("from index 'DataIndex' where moreLikeThis(id() = $p0) and body = $p1"); + + assert.ok(list.length > 0); + } + }); + it("can get results using term vectors and storage", async () => { let id: string; {