fabriziofortino commented on code in PR #2269: URL: https://github.com/apache/jackrabbit-oak/pull/2269#discussion_r2075623929
########## oak-query-spi/src/main/java/org/apache/jackrabbit/oak/spi/query/fulltext/InferenceQueryConfig.java: ########## @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.jackrabbit.oak.spi.query.fulltext; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class InferenceQueryConfig { + public static final String TYPE = "inferenceModelConfig"; + @Nullable + private final String inferenceModelConfig; + + private static final ObjectMapper objectMapper = new ObjectMapper(); + + public InferenceQueryConfig(@NotNull String queryConfig) { + if (queryConfig.isBlank()){ + this.inferenceModelConfig = null; + return; + } else if (queryConfig.equals("{}")) { + // in this case a default inferenceModelConfig will be used. + this.inferenceModelConfig = ""; + } else { + try { + JsonNode jsonNode1 = objectMapper.readTree(queryConfig); + inferenceModelConfig = jsonNode1.get(TYPE).asText(); + } catch (JsonProcessingException e) { + throw new RuntimeException("Error parsing inference query config: "+ queryConfig + "error message:" + e.getMessage()); Review Comment: missing spaces ```suggestion throw new RuntimeException("Error parsing inference query config: " + queryConfig + "error message: " + e.getMessage()); ``` ########## oak-query-spi/src/main/java/org/apache/jackrabbit/oak/spi/query/fulltext/InferenceQueryConfig.java: ########## @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.jackrabbit.oak.spi.query.fulltext; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class InferenceQueryConfig { + public static final String TYPE = "inferenceModelConfig"; + @Nullable + private final String inferenceModelConfig; + + private static final ObjectMapper objectMapper = new ObjectMapper(); + + public InferenceQueryConfig(@NotNull String queryConfig) { + if (queryConfig.isBlank()){ + this.inferenceModelConfig = null; + return; Review Comment: this can be removed ```suggestion ``` ########## oak-query-spi/src/test/java/org/apache/jackrabbit/oak/spi/query/fulltext/InferenceQueryTest.java: ########## @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.jackrabbit.oak.spi.query.fulltext; + +import org.junit.Test; + +import static org.junit.Assert.*; Review Comment: do not use wildcards in imports ########## oak-query-spi/src/test/java/org/apache/jackrabbit/oak/spi/query/fulltext/InferenceQueryConfigTest.java: ########## @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.jackrabbit.oak.spi.query.fulltext; + +import org.junit.Test; +import static org.junit.Assert.*; Review Comment: do not use wildcards in imports ########## oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java: ########## @@ -137,27 +138,37 @@ public FullTextExpression getFullTextConstraint(SelectorImpl s) { } String p2 = normalizePropertyName(p); String rawText = getRawText(v); - FullTextExpression e = FullTextParser.parse(p2, rawText); + String queryText = rawText; + // To use inference we need to add inferenceconfig information in query. The format for the query is + // <inferenceprefix><json with inferenceModelConfig><inferencePrefix> Review Comment: typo ```suggestion // <inferencePrefix><json with inferenceModelConfig><inferencePrefix> ``` ########## oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/inference/InferenceConfig.java: ########## @@ -0,0 +1,226 @@ +/* Review Comment: would it make sense to move all these classes you have in this package in oak-search instead of oak-search-elastic? ########## oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/inference/VectorDocument.java: ########## @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.jackrabbit.oak.plugins.index.elastic.query.inference; + +import java.util.List; +import java.util.Map; + +public class VectorDocument { Review Comment: is this used only in tests? Can we move it to the test folder? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: oak-dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org