Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ void bm25() {
PlanSearchOptions options = op.searchOptions()
.withScoreMethod(PlanSearchOptions.ScoreMethod.BM25)
.withBm25LengthWeight(0.25);
List<RowRecord> rows = resultRows(
op.fromSearchDocs(op.cts.wordQuery("contents"), null, options)
.offsetLimit(0, 5)
);
assertEquals(5, rows.size());
List<RowRecord> rows = resultRows(op.fromSearchDocs(op.cts.wordQuery("saxophone"), null, options));
assertEquals(2, rows.size());
}

@Test
Expand All @@ -36,10 +33,7 @@ void qualityWeight() {
// It only tests that including a valid qualityWeight value does not cause any problems.
rowManager.withUpdate(false);
PlanSearchOptions options = op.searchOptions().withScoreMethod(PlanSearchOptions.ScoreMethod.LOGTFIDF).withQualityWeight(0.75F);
List<RowRecord> rows = resultRows(
op.fromSearchDocs(op.cts.wordQuery("contents"), null, options)
.offsetLimit(0, 5)
);
assertEquals(5, rows.size());
List<RowRecord> rows = resultRows(op.fromSearchDocs(op.cts.wordQuery("saxophone"), null, options));
assertEquals(2, rows.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ void bm25() {
PlanSearchOptions options = op.searchOptions()
.withScoreMethod(PlanSearchOptions.ScoreMethod.BM25)
.withBm25LengthWeight(0.25);
List<RowRecord> rows = resultRows(
op.fromSearch(op.cts.wordQuery("contents"), null, null, options)
.offsetLimit(0, 5)
);
assertEquals(5, rows.size());
List<RowRecord> rows = resultRows(op.fromSearch(op.cts.wordQuery("saxophone"), null, null, options));
assertEquals(2, rows.size());
}

@Test
Expand All @@ -36,8 +33,7 @@ void badBm25LengthWeight() {
PlanSearchOptions options = op.searchOptions()
.withScoreMethod(PlanSearchOptions.ScoreMethod.BM25)
.withBm25LengthWeight(99);
PlanBuilder.ModifyPlan plan = op.fromSearch(op.cts.wordQuery("contents"), null, null, options)
.offsetLimit(0, 5);
PlanBuilder.ModifyPlan plan = op.fromSearch(op.cts.wordQuery("saxophone"), null, null, options);
Exception exception = assertThrows(FailedRequestException.class, () -> resultRows(plan));
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains("Server Message: XDMP-OPTION"));
Expand All @@ -48,11 +44,8 @@ void badBm25LengthWeight() {
void zero() {
rowManager.withUpdate(false);
PlanSearchOptions options = op.searchOptions().withScoreMethod(PlanSearchOptions.ScoreMethod.ZERO);
List<RowRecord> rows = resultRows(
op.fromSearch(op.cts.wordQuery("contents"), null, null, options)
.offsetLimit(0, 5)
);
assertEquals(5, rows.size());
List<RowRecord> rows = resultRows(op.fromSearch(op.cts.wordQuery("saxophone"), null, null, options));
assertEquals(2, rows.size());
rows.forEach(row -> {
assertEquals(0, row.getInt("score"), "The score for every row should be 0.");
});
Expand All @@ -64,10 +57,7 @@ void qualityWeight() {
// It only tests that including a valid qualityWeight value does not cause any problems.
rowManager.withUpdate(false);
PlanSearchOptions options = op.searchOptions().withScoreMethod(PlanSearchOptions.ScoreMethod.LOGTFIDF).withQualityWeight(0.75F);
List<RowRecord> rows = resultRows(
op.fromSearch(op.cts.wordQuery("contents"), null, null, options)
.offsetLimit(0, 5)
);
assertEquals(5, rows.size());
List<RowRecord> rows = resultRows(op.fromSearch(op.cts.wordQuery("saxophone"), null, null, options));
assertEquals(2, rows.size());
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.marklogic.client.test.rows;

import com.fasterxml.jackson.databind.node.TextNode;
import com.marklogic.client.row.RowRecord;
import com.marklogic.client.test.junit5.RequiresML12;
import com.marklogic.client.test.junit5.RequiresMLElevenDotOne;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand Down Expand Up @@ -57,30 +58,36 @@ void joinDocAndUri() {
}

@Test
@Disabled("See DBQ-643")
// Fixed via MLE-55
@ExtendWith(RequiresML12.class)
void documentRootQuery() {
List<RowRecord> rows = resultRows(op
.fromDocUris(op.cts.documentRootQuery("suggest"))
);

assertEquals(2, rows.size());
assertEquals("/sample/suggestion.xml", rows.get(0).get("uri"));
assertEquals("/sample2/suggestion.xml", rows.get(1).get("uri"));
assertEquals("/sample/suggestion.xml", ((TextNode) rows.get(0).get("uri")).asText());
assertEquals("/sample2/suggestion.xml", ((TextNode) rows.get(1).get("uri")).asText());
}

@Test
@Disabled("See DBQ-643")
// Fixed via MLE-55
@ExtendWith(RequiresML12.class)
void documentFormatQuery() {
List<RowRecord> rows = resultRows(op
.fromDocUris(op.cts.documentFormatQuery("text"))
.fromDocUris(op.cts.andQuery(
op.cts.documentFormatQuery("text"),
op.cts.collectionQuery("document-format-query-test")
))
);

assertEquals(1, rows.size());
assertEquals("/sample/second.txt", rows.get(0).get("uri"));
assertEquals("/sample/second.txt", ((TextNode) rows.get(0).get("uri")).asText());
}

@Test
@Disabled("See DBQ-643")
// Fixed via MLE-55
@ExtendWith(RequiresML12.class)
void documentPermissionQuery() {
List<RowRecord> rows = resultRows(op
.fromDocUris(op.cts.documentPermissionQuery("rest-reader", "read"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void vectorFunctionsHappyPath() {
.limit(5);
List<RowRecord> rows = resultRows(plan);
assertEquals(2, rows.size());

rows.forEach(row -> {
// Simple a sanity checks to verify that the functions ran. Very little concern about the actual return values.
double cosineSimilarity = row.getDouble("cosineSimilarity");
Expand Down Expand Up @@ -89,7 +90,7 @@ void cosineSimilarity_DimensionMismatch() {
Exception exception = assertThrows(FailedRequestException.class, () -> resultRows(plan));
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains("Server Message: VEC-DIMMISMATCH"), "Unexpected message: " + actualMessage);
assertTrue(actualMessage.contains("Mismatched dimension: Vector dimensions must be equal"), "Unexpected message: " + actualMessage);
assertTrue(actualMessage.contains("Mismatched dimension"), "Unexpected message: " + actualMessage);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*=rest-reader,read,rest-writer,update
1 change: 1 addition & 0 deletions test-app/src/main/ml-data/sample/collections.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ suggestion.xml=http://some.org/suggestions
first.xml=http://some.org/collection1,http://some.org/collection2
lexicon-test1.xml=http://some.org/collection1,http://some.org/collection2
lexicon-test2.xml=http://some.org/collection1,http://some.org/collection2
second.txt=document-format-query-test