Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
de687a4
Add JsonPathValidator and $alias for SearchableProperties
Ardacry Oct 27, 2025
7d497ed
Add JsonPathValidator and $alias for SearchableProperties
Ardacry Oct 27, 2025
e1cd9af
Add JsonPathValidator and $alias for SearchableProperties
Ardacry Oct 27, 2025
0bcf1b2
Add function to validator and corrected $alias to Space model
Ardacry Oct 28, 2025
400425a
Move JsonPathValidator classes and add validation in Space Model
Ardacry Oct 28, 2025
ba76615
Add user provided alias support and uniqueness check
Ardacry Oct 31, 2025
d601735
Search API changes for JsonPaths
Ardacry Nov 26, 2025
2666c66
Add JsonPathValidator and $alias for SearchableProperties
Ardacry Oct 27, 2025
6d3f9dd
Add JsonPathValidator and $alias for SearchableProperties
Ardacry Oct 27, 2025
125c01f
Add JsonPathValidator and $alias for SearchableProperties
Ardacry Oct 27, 2025
030c323
Add function to validator and corrected $alias to Space model
Ardacry Oct 28, 2025
627fcaf
Move JsonPathValidator classes and add validation in Space Model
Ardacry Oct 28, 2025
057c4ee
Add user provided alias support and uniqueness check
Ardacry Oct 31, 2025
4173bea
Search API changes for JsonPaths
Ardacry Nov 26, 2025
ed0afbb
Add brackets and properly store Jsonpaths
Ardacry Nov 26, 2025
f48eab8
Merge remote-tracking branch 'origin/jsonPathValidation' into jsonPat…
Ardacry Nov 26, 2025
7d3752c
Backwards compatible parsing of new JsonPath keys in Space.java
Ardacry Nov 27, 2025
c89f86d
Add new key form compatibility to IndexHelper.java
Ardacry Nov 27, 2025
3d46e2f
Seperate canonical and old keys, use alias as key only in Space model
Ardacry Nov 27, 2025
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
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2019 HERE Europe B.V.
* Copyright (C) 2017-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@
package com.here.xyz.hub.rest;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import com.here.xyz.events.PropertiesQuery;
import com.here.xyz.events.PropertyQuery;
Expand Down Expand Up @@ -69,7 +70,6 @@ public void parsePropertiesQuery() {
assertEquals(2, query.getValues().size());
assertEquals("string", query.getValues().get(0));
assertEquals("5", query.getValues().get(1));

}

@Test
Expand Down Expand Up @@ -148,4 +148,93 @@ public void parsePropertiesQuerySpace() {
assertEquals(1, query.getValues().size());
assertEquals(3L, query.getValues().get(0));
}

@Test
public void parsePropertiesQueryJsonPath() {
String URIquery = "p.jsonPath=$.properties.address.city";
PropertiesQuery pq = PropertiesQuery.fromString(URIquery, "", false);

assertEquals("1 OR block is expected", 1, pq.size());
PropertyQueryList pql = pq.get(0);
assertEquals("1 AND block is expected.", 1, pql.size());

PropertyQuery query = pql.stream()
.filter(q -> q.getKey().equals("properties.jsonPath"))
.findFirst()
.get();

assertEquals(QueryOperation.EQUALS, query.getOperation());
assertEquals(1, query.getValues().size());
Object value = query.getValues().get(0);
assertTrue("JSONPath value should be a String", value instanceof String);
assertEquals("$.properties.address.city", value);
}

@Test
public void parsePropertiesQueryJsonPathWithOtherFilters() {
String URIquery =
"p.jsonPath=$.properties.address.city"
+ "&p.a=3"
+ "&p.boolean=true"
+ "&f.createdAt>0";

PropertiesQuery pq = PropertiesQuery.fromString(URIquery, "", false);
assertEquals("1 OR block is expected", 1, pq.size());

PropertyQueryList pql = pq.get(0);
// 4 AND blocks: jsonPath, a, boolean, createdAt
assertEquals("4 AND blocks are expected.", 4, pql.size());

// jsonPath
PropertyQuery query = pql.stream()
.filter(q -> q.getKey().equals("properties.jsonPath"))
.findFirst()
.get();
assertEquals(QueryOperation.EQUALS, query.getOperation());
assertEquals(1, query.getValues().size());
assertTrue(query.getValues().get(0) instanceof String);
assertEquals("$.properties.address.city", query.getValues().get(0));

// properties.a (still parsed as number)
query = pql.stream().filter(q -> q.getKey().equals("properties.a")).findFirst().get();
assertEquals(QueryOperation.EQUALS, query.getOperation());
assertEquals(1, query.getValues().size());
assertEquals(3L, query.getValues().get(0));

// properties.boolean (still parsed as boolean)
query = pql.stream().filter(q -> q.getKey().equals("properties.boolean")).findFirst().get();
assertEquals(QueryOperation.EQUALS, query.getOperation());
assertEquals(1, query.getValues().size());
assertEquals(true, query.getValues().get(0));

// createdAt (mapped via SEARCH_KEY_REPLACEMENTS)
query = pql.stream()
.filter(q -> q.getKey().equals("properties.@ns:com:here:xyz.createdAt"))
.findFirst()
.get();
assertEquals(QueryOperation.GREATER_THAN, query.getOperation());
assertEquals(1, query.getValues().size());
assertEquals(0L, query.getValues().get(0));
}

@Test
public void parsePropertiesQuerySpaceJsonPath() {
String URISpaceQuery = "a=1&b=2&jsonPath=$.space.properties.version";
PropertiesQuery pq = PropertiesQuery.fromString(URISpaceQuery, "jsonPath", true);

assertEquals("1 OR block is expected", 1, pq.size());
PropertyQueryList pql = pq.get(0);
assertEquals("1 AND block is expected.", 1, pql.size());

PropertyQuery query = pql.stream()
.filter(q -> q.getKey().equals("jsonPath"))
.findFirst()
.get();

assertEquals(QueryOperation.EQUALS, query.getOperation());
assertEquals(1, query.getValues().size());
Object value = query.getValues().get(0);
assertTrue("JSONPath value should be a String", value instanceof String);
assertEquals("$.space.properties.version", value);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2019 HERE Europe B.V.
* Copyright (C) 2017-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -155,6 +155,11 @@ public static String getConvertedKey(String rawKey) {
}

public static Object getConvertedValue(String rawValue) {
// JSONPath
if (rawValue != null && rawValue.startsWith("$")) {
return rawValue;
}

// Boolean
if (rawValue.equals("true")) {
return true;
Expand Down Expand Up @@ -196,4 +201,23 @@ private static String transformLegacyTags(String legacyTagsQuery) {

return F_PREFIX + "tags" + "=cs=" + tags;
}

public List<String> getJsonPathValues() {
List<String> jsonPaths = new ArrayList<>();

for (PropertyQueryList queries : this) {
for (PropertyQuery query : queries) {
for (Object value : query.getValues()) {
if (value instanceof String) {
String s = (String) value;
if (s.startsWith("$")) {
jsonPaths.add(s);
}
}
}
}
}

return jsonPaths;
}
}
Loading