Skip to content

Commit

Permalink
Similarity search field now accepts key:value filters that contain co…
Browse files Browse the repository at this point in the history
…lon ":" in the value + fix bug on "Load More" when search filter is active (#221)

* Similarity search field now accepts key:value filters that contain a colon ":" in the value

* Fixed "Load More" action when a search filter is active
  • Loading branch information
fschuh authored Oct 6, 2024
1 parent 4e39b5b commit 6498cd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/components/Points/PointsTabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ const PointsTabs = ({ collectionName, client }) => {
}
setOffset(null);
setConditions(conditions);
if (conditions.length === 0) {
setPoints({ points: [] });
}
setPoints({ points: [] });
};

const deletePoint = (collectionName, pointIds) => {
Expand Down Expand Up @@ -98,15 +96,16 @@ const PointsTabs = ({ collectionName, client }) => {
setErrorMessage(null);
} else if (filters.length !== 0) {
const newPoints = await qdrantClient.scroll(collectionName, {
offset,
filter: {
must: filters,
},
limit: pageSize + (offset || 0),
limit: pageSize,
with_payload: true,
with_vector: true,
});
setPoints({
points: [...(newPoints?.points || [])],
points: [...(points?.points || []), ...(newPoints?.points || [])],
});
setNextPageOffset(newPoints?.next_page_offset);
setErrorMessage(null);
Expand Down
12 changes: 6 additions & 6 deletions src/components/Points/SimilarSerachfield.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ function SimilarSerachfield({ conditions, onConditionChange, vectors, usingVecto

const handleAddChip = (chip) => {
setErrorMessage(null);
const keyValue = chip.split(':');
if (keyValue.length !== 2) {
const keyValue = chip.split(/:(.*)/);
if (keyValue.length < 2 || !keyValue[0].trim()) {
setErrorMessage('Invalid format of key:value pair');
return;
}
const key = keyValue[0].trim();
const parseToPrimitive = (keyValue) => {
const parseToPrimitive = (value) => {
try {
return bigIntJSON.parse(keyValue[1].trim());
return bigIntJSON.parse(value);
} catch (e) {
return keyValue[1].trim();
return value;
}
};
const value = parseToPrimitive(keyValue);
const value = parseToPrimitive(keyValue[1].trim());
if (key === 'id') {
if (value && (typeof value === 'number' || typeof value === 'bigint' || validateUuid(value))) {
const id = {
Expand Down

0 comments on commit 6498cd4

Please sign in to comment.