Querying a content property in Confluence P2 plugin

Hello Guys,

I want to create a customized CQL field that searches for a content property inside my confluence,
I did the following:
1- Creating a content property via REST post method
2- Indexing this content property by configuring content-property-index-schema inside my atlassian-plugin
=> now my content property is searchable , as I tried to search for it in the search rest call by adding the following in cql parameter of api/search method : content.property[mxdoc1].fileid=1234 => I got results
Now , using CQL field, I discovered that we are calling TermQuery(fieldName, value) that does the query via code. But, what should I put as 1st parameter:fieldName ? How Lucene stored this fieldName?
Can you please help?

thanks,
Rosy

Hello,

Did anyone have the opportunity to check above?
I appreciate your help.
thanks,
Rosy

I have never done that, but I know Confluence has a kind of “Lucene browser” where you can see how data is stored in Lucene. Try browsing the index and see whether you see your data.

(Sorry, that’s not much help, just a lead)

thanks a lot @playsql, this is what I"m trying to do. the software is called Luke, I installed it and picked my “index” folder but, I’m having the following:
java.lang.IllegalArgumentException: A SPI class of type org.apache.lucene.codecs.Codec with name ‘Lucene42’ does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.The current classpath supports the following names: [Lucene40, Lucene3x, SimpleText, Appending]

I checked the solution in the follwoing , but, I don’t know where to put this folder and file:
https://anwaarlabs.wordpress.com/2017/02/25/lucene-an-spi-class-of-type-org-apache-lucene-codecs-codec-with-name-does-not-exist/:

Regards,
Rosy

Hello,
You need a specific version of Luke. Lucene had many updates which made the API change a lot, so there is no compatibility between two versions. The error message says you need the codec for Lucene42 and you have codecs for Lucene40 and Lucene3x. The Lucene42 codec has been introduced in Lucene 4.6.0 so you need Luke in version 4.6.0 as well.
Don’t forget that sometimes you’ll need to check “Open in Read-Only” and “Force unlock”, especially if your Confluence application is still running.

Hope this helps

Thanks a lot @rchaput, I will try that and get back to you! :slight_smile

Many thanks,
Rosy

Thnaks a lot @rchaput for your help, it worked! :slight_smile:
Now, I will try to analyze the contents!
Rosy

The last time I did this kind of thing, which was some time ago and probably with Confluence 5.x, I used lukeall-4.7.1.jar - I have a copy if you can’t locate it - mail me david @ davidsimpson.me if you can’t find it.

thanks @david, it worked after applying rchaput’s suggestion :slight_smile:

1 Like

Hello again guys,

Now, I was able to detect the fiedName parameter of TermQuery via Luke and I got results (please check attached snapshot), but, when I"m calling it inside my code using the same key, I"m not getting any results in my CQL field, any idea how to debug the query behind it in my code? Or, is there something missing?

 @Override
    public V2SearchQueryWrapper build(SetExpressionData setExpressionData, Iterable<String> values)
    {
    	validateSupportedOp(setExpressionData.getOperator(), newHashSet(IN, NOT_IN));
        SearchQuery query = joinSingleValueQueries(values, new Function<String, TermQuery>(){
            @Override
            public TermQuery apply(@Nullable String value)
            {
                return createEqualityQuery(value);
            }
        });
        return wrapV2Search(query, setExpressionData);
    }

    @Override
    public V2SearchQueryWrapper build(EqualityExpressionData equalityExpressionData, String value)
    {
    	 
        validateSupportedOp(equalityExpressionData.getOperator(), newHashSet(EQUALS, NOT_EQUALS));
        TermQuery term =  createEqualityQuery(value);
        return wrapV2Search(createEqualityQuery(value), equalityExpressionData);
    }

    private TermQuery createEqualityQuery(String value)
    {
         return new TermQuery("content-property-mxdoc-fileid", value);
    }

Thanks,
Rosy

I appreciate your help as I’m stuck on that a week ago and I"m not able to fix my problem.

thank you,
Rosy