-
Notifications
You must be signed in to change notification settings - Fork 25.5k
ES|QL - kNN function initial support #127322
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
Changes from all commits
6f4d011
3c4c401
8317911
e7736be
9588048
0f77374
891f4fc
fb2a3c7
8e9b280
0f58f24
e92c92b
1b7f02f
e44745e
bf92cf4
e1aecf0
239cf1e
1837242
c203766
7ae9909
204efda
1dd6008
e4f31fc
0d5a66a
ad34463
aa97b8a
26f48e7
e7452dd
22efe27
7f5ddde
b352673
66f8496
f756e85
34968ad
77011c1
d60c8e5
eacb9a0
03a329a
fbe8b6c
6ea4995
d28f2ea
9caed86
e8d8c25
958dfba
f2975a3
7a18aec
fccf9a5
3d70558
19548fa
22a4c26
ce64ba9
e114453
a34fc89
6fe7b2a
a258820
9227dc7
d3262a4
cc81380
be1e578
524c93c
65b3256
853e096
dc71549
97b6c63
c3388de
d824faa
78aa6d0
47b91f5
52f057b
68ec878
12fb39c
36c26a5
b86f2fc
c5b1292
bea423f
da4d5bc
49addf3
d1cd92c
1842ab4
a03ec92
aaf8684
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,7 @@ private Vector evalSingleSegmentNonDecreasing(DocVector docs) throws IOException | |
int min = docs.docs().getInt(0); | ||
int max = docs.docs().getInt(docs.getPositionCount() - 1); | ||
int length = max - min + 1; | ||
try (T scoreBuilder = createVectorBuilder(blockFactory, length)) { | ||
try (T scoreBuilder = createVectorBuilder(blockFactory, docs.getPositionCount())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When testing using random indexing and deletions, it became apparent that we need to use getPositionCount() instead of length, as length can be greater than position counts. |
||
if (length == docs.getPositionCount() && length > 1) { | ||
return segmentState.scoreDense(scoreBuilder, min, max); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1022,7 +1022,7 @@ public void testMultipleBatchesWithLookupJoin() throws IOException { | |
var query = requestObjectBuilder().query(format(null, "from * | lookup join {} on integer {}", testIndexName(), sort)); | ||
Map<String, Object> result = runEsql(query); | ||
var columns = as(result.get("columns"), List.class); | ||
assertEquals(21, columns.size()); | ||
assertEquals(22, columns.size()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We added dense_vector to mappings-all-types, so a new column was added |
||
var values = as(result.get("values"), List.class); | ||
assertEquals(10, values.size()); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,7 @@ public class CsvTestsDataLoader { | |
private static final TestDataset LOGS = new TestDataset("logs"); | ||
private static final TestDataset MV_TEXT = new TestDataset("mv_text"); | ||
private static final TestDataset DENSE_VECTOR = new TestDataset("dense_vector"); | ||
private static final TestDataset COLORS = new TestDataset("colors"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think colors dataset is very intuitive for vector similarity tests - looking for RGB similar colors looks better than looking for random vectors IMO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Smart!!! |
||
|
||
public static final Map<String, TestDataset> CSV_DATASET_MAP = Map.ofEntries( | ||
Map.entry(EMPLOYEES.indexName, EMPLOYEES), | ||
|
@@ -210,7 +211,8 @@ public class CsvTestsDataLoader { | |
Map.entry(SEMANTIC_TEXT.indexName, SEMANTIC_TEXT), | ||
Map.entry(LOGS.indexName, LOGS), | ||
Map.entry(MV_TEXT.indexName, MV_TEXT), | ||
Map.entry(DENSE_VECTOR.indexName, DENSE_VECTOR) | ||
Map.entry(DENSE_VECTOR.indexName, DENSE_VECTOR), | ||
Map.entry(COLORS.indexName, COLORS) | ||
); | ||
|
||
private static final EnrichConfig LANGUAGES_ENRICH = new EnrichConfig("languages_policy", "enrich-policy-languages.json"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
color:text,hex_code:keyword,rgb_vector:dense_vector,primary:boolean | ||
maroon, #800000, [128,0,0], false | ||
brown, #A52A2A, [165,42,42], false | ||
firebrick, #B22222, [178,34,34], false | ||
crimson, #DC143C, [220,20,60], false | ||
red, #FF0000, [255,0,0], true | ||
tomato, #FF6347, [255,99,71], false | ||
coral, #FF7F50, [255,127,80], false | ||
salmon, #FA8072, [250,128,114], false | ||
orange, #FFA500, [255,165,0], false | ||
gold, #FFD700, [255,215,0], false | ||
golden rod, #DAA520, [218,165,32], false | ||
khaki, #F0E68C, [240,230,140], false | ||
olive, #808000, [128,128,0], false | ||
yellow, #FFFF00, [255,255,0], true | ||
chartreuse, #7FFF00, [127,255,0], false | ||
green, #008000, [0,128,0], true | ||
lime, #00FF00, [0,255,0], false | ||
teal, #008080, [0,128,128], false | ||
cyan, #00FFFF, [0,255,255], true | ||
turquoise, #40E0D0, [64,224,208], false | ||
aqua marine, #7FFFD4, [127,255,212], false | ||
navy, #000080, [0,0,128], false | ||
blue, #0000FF, [0,0,255], true | ||
indigo, #4B0082, [75,0,130], false | ||
purple, #800080, [128,0,128], false | ||
thistle, #D8BFD8, [216,191,216], false | ||
plum, #DDA0DD, [221,160,221], false | ||
violet, #EE82EE, [238,130,238], false | ||
magenta, #FF00FF, [255,0,255], true | ||
orchid, #DA70D6, [218,112,214], false | ||
pink, #FFC0CB, [255,192,203], false | ||
beige, #F5F5DC, [245,245,220], false | ||
bisque, #FFE4C4, [255,228,196], false | ||
wheat, #F5DEB3, [245,222,179], false | ||
corn silk, #FFF8DC, [255,248,220], false | ||
lemon chiffon, #FFFACD, [255,250,205], false | ||
sienna, #A0522D, [160,82,45], false | ||
chocolate, #D2691E, [210,105,30], false | ||
peru, #CD853F, [205,133,63], false | ||
burly wood, #DEB887, [222,184,135], false | ||
tan, #D2B48C, [210,180,140], false | ||
moccasin, #FFE4B5, [255,228,181], false | ||
peach puff, #FFDAB9, [255,218,185], false | ||
misty rose, #FFE4E1, [255,228,225], false | ||
linen, #FAF0E6, [250,240,230], false | ||
old lace, #FDF5E6, [253,245,230], false | ||
papaya whip, #FFEFD5, [255,239,213], false | ||
sea shell, #FFF5EE, [255,245,238], false | ||
mint cream, #F5FFFA, [245,255,250], false | ||
lavender, #E6E6FA, [230,230,250], false | ||
honeydew, #F0FFF0, [240,255,240], false | ||
ivory, #FFFFF0, [255,255,240], false | ||
azure, #F0FFFF, [240,255,255], false | ||
snow, #FFFAFA, [255,250,250], false | ||
black, #000000, [0,0,0], true | ||
gray, #808080, [128,128,128], true | ||
silver, #C0C0C0, [192,192,192], false | ||
gainsboro, #DCDCDC, [220,220,220], false | ||
white, #FFFFFF, [255,255,255], true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
dense_vector
field mapping tomapping-all-fields
uncovered a bug - if no dimensions are set, a NPE was thrown when creating the BlockLoaders.I can create a separate PR for this, but seemed unnecessary as it implied just this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering if a test could be added for this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, added in 36c26a5