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();
}
```
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.