googleads / googleads/googleads-java-lib
Issue searching audience segments with name starting from the search term
Open
@christopherseeley is already working on this.
Since Apr 14, 2021.
- Dominant language
- Java
- Stars
- 234
- Forks
- 360
- PR merge metrics
- No merged PRs in 30d
Description
Hi All,
I'm trying to request all audience segments which start from "PA - " but the API looks like returns audience segments with the search term not only at the beginning of the name, but also in any part of the name.
This is how my code looks like:
@Override
public List<AudienceSegment> findAllPAs() {
StatementBuilder statementBuilder =
new StatementBuilder()
.where("name LIKE 'PA - %' and type = 'FIRST_PARTY'")
.orderBy("id ASC");
return findAllAudienceSegmentsByStatement(statementBuilder, StatementBuilder.SUGGESTED_PAGE_LIMIT);
}
private List<AudienceSegment> findAllAudienceSegmentsByStatement(StatementBuilder statement, int limit) {
statement.limit(limit);
List<AudienceSegment> segments = new ArrayList<>();
int totalResultSetSize = 0;
do {
AudienceSegmentPage page;
try {
page = audienceSegmentService.getAudienceSegmentsByStatement(statement.toStatement());
} catch (RemoteException re) {
throw new RuntimeException(re);
}
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
segments.addAll(Arrays.asList(page.getResults()));
}
statement.increaseOffsetBy(limit);
} while (statement.getOffset() < totalResultSetSize);
return segments;
}
Thanks,
Andrei
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.