javascript - ArangoDB Query for consecutive matches to an array -
in arangodb need search number of consecutive matches array within document integer matrix.
example document (all int[5][5])
:
nums: 25, 32, 26, 27, 29 01, 22, 15, 17, 99 12, 14, 17, 19, 88 16, 14, 12, 17, 19 02, 08, 09, 18, 19
and in java have int[5] example.:
22, 23, 24, 25, 26
i need return documents in of following true:
at least 4 numbers java array match @ least 4 consecutive numbers in matrix row. eg. if matrix row has 22, 23, **29**, 24, 25
not match because no set of 4 numbers array next eachother (it doesn't matter, however, if order matches of array). however, if 22, 26, 23, 24
match because there @ least 4 consecutive numbers array. eg:
**22**, 32, 26, 27, 29 **26**, 22, 15, 17, 99 **23**, 14, 17, 19, 88 **24**, 14, 12, 17, 19 02, 08, 09, 18, 19
the same above in matrix column instead of row
20, 01, 02, 03, 08 01,*22,*23*,*25*,*24* 12, 14, 17, 19, 88 16, 14, 12, 17, 19 02, 08, 09, 18, 19
the same last 2 diagonally, instead of in row or column
**22**, 32, 26, 27, 29 01, 02, 03, 04, 05 01, **23**, 15, 17, 99 06, 07, 08, **24**, 10 12, 14, **26**, 19, 88 11, 12, **23**, 14, 15 16, 14, 12, **25**, 19 16, **25**, 18, 19, 20 02, 08, 09, 18, 19 **22**, 22, 23, 24, 25
no 2 numbers in matrix same. eg, there not number 1
more once in entire matrix.
i'm not sure how approach such problem. moment querying documents have @ least 4 numbers in matrix match array's numbers, imagine there way query this. can think of doing generating combination of every possible matrix query matching matrices, isn't realistic.
update: regarding answer recommends using js extension, how 1 go doing solve problem? not familiar arangodb extensions.
it might bit contrived pure aql, i'd recommend checking out adding own js function match (see https://docs.arangodb.com/aqlextending/index.html)
would pretty easy js, , use filter match.
Comments
Post a Comment