Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sort Order Support to /terms API Request #3735

Closed
wants to merge 3 commits into from
Closed

Add Sort Order Support to /terms API Request #3735

wants to merge 3 commits into from

Conversation

billmurrin
Copy link
Contributor

Description

This changes adds order as an option when conducting an /search/universal/relative/terms API query. This will allow the web interface to request ascending ordered term aggregations via the REST API.

Motivation and Context

  • PR Update Terms Method to Support Ascending and Descending Ordering #3540 added sort order support to the Searches.terms method for sort order. This PR adds it to the Graylog API so that the web interface can take advantage of it via REST queries.
  • Right now, a term aggregation returned from a REST query can only be ordered Ascending in a generic manner since the underlying query is ordered in a descending manner.
  • This PR fixes a bug I am experiencing in my QuickValuesPlus Widget Plugin More Info

How Has This Been Tested?

  • I compiled the Graylog 2.3.0 SNAPSHOT with the incorporated changes and then replaced the graylog.jar file under /opt/graylog/server. Once the server loaded, I validated the latest SNAPSHOT version "2.3.0-SNAPSHOT+252f9fe" was loaded. I went into the API Browser on the node and validated under "GET /search/universal/relative/terms" that the order field was present.
  • I tested it with values for asc, desc, and blank and was able to see that the underlying JSON query contained the proper sort syntax. The results also indicated the query was providing the correct data.
  • No unit testing on the code change was conducted.
  • No errors were observed.

Screenshots (if appropriate):

alt text

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

checkSearchPermission(filter, RestPermissions.SEARCHES_RELATIVE);

final Sorting.Direction sortOrder;

if (isNullOrEmpty(order)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use buildSorting() here, also see Sorting.

@billmurrin
Copy link
Contributor Author

@joschi. Added buildSorting method support. In order to return the Direction from the Sorting class (Searches.terms expects a Sorting.Direction object) I added a getDirection method to the Sorting class. Your review is appreciated.

@joschi
Copy link
Contributor

joschi commented May 16, 2017

Superseded by #3829

@joschi joschi closed this May 16, 2017
@joschi
Copy link
Contributor

joschi commented May 16, 2017

@billmurrin Thank you very much for your contribution! We've merged the rebased PR into master (76b9703).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants