Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

SearchManager filter with content Id

Acc3 Reversing
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 21, 2025

Hello, I want to do filter with content Id using SearchManager. but, the server failed to search results with "id" field. How can I solve this problem?

 

Here's my code.

 

```

Set<SearchQuery> queries = new HashSet<>();

// ONLY PAGE, BLOGPOST, COMMENT, ATTACHMENT
Set<SearchQuery> typeQueries = new HashSet<>();
typeQueries.add(new ContentTypeQuery(ContentTypeEnum.BLOG));
typeQueries.add(new ContentTypeQuery(ContentTypeEnum.PAGE));
typeQueries.add(new ContentTypeQuery(ContentTypeEnum.COMMENT));
typeQueries.add(new ContentTypeQuery(ContentTypeEnum.ATTACHMENT));

SearchQuery contentTypeQuery = BooleanQuery.composeOrQuery(typeQueries);
queries.add(contentTypeQuery);

// id > startId filter
SearchQuery contentIdQuery = new LongRangeQuery(
    "id",
    new Range<>(
        startId,
        null,
        true,
        false
    )
);
queries.add(contentIdQuery);

 

try{
    // generate final query
    SearchQuery finalQuery = BooleanQuery.composeAndQuery(queries);
    SearchSort sort = new ContentIdSort(SearchSort.Order.ASCENDING);
    ContentSearch contentSearch = new ContentSearch(
        finalQuery,
        sort,
        null,
        0, maxResult
    );

   

    // search results

    SearchResults result = mSearchManager.search(contentSearch);
    LOGGER.warn("[DaemonSchd] Query: {}", result.getSearchQuery());
    if(result.size() == 0)
        return Collections.emptyList();

    

    // return result
    return result.getAll();
} catch (Exception e){
    LOGGER.error("Failed to search targets.", e);
    return Collections.emptyList();
}

```

1 answer

0 votes
John Funk
Community Champion
May 6, 2025

Hi @Acc3 Reversing  - Welcome to the Atlassian Community!

Since no one has answered yet, you probably should open a support ticket with Atlassian for their feedback. Please post back here with the solution. 

https://support.atlassian.com/contact/#/

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.19.6
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events