-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bug/job-facets-foreign-key-constraints
- Loading branch information
Showing
46 changed files
with
1,591 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ API_PORT=5000 | |
API_ADMIN_PORT=5001 | ||
WEB_PORT=3000 | ||
POSTGRES_PORT=5432 | ||
SEARCH_PORT=9200 | ||
TAG=0.49.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright 2018-2024 contributors to the Marquez project | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package marquez.api.v2beta; | ||
|
||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | ||
|
||
import com.codahale.metrics.annotation.ExceptionMetered; | ||
import com.codahale.metrics.annotation.ResponseMetered; | ||
import com.codahale.metrics.annotation.Timed; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import javax.validation.constraints.NotBlank; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.QueryParam; | ||
import javax.ws.rs.core.Response; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
import lombok.ToString; | ||
import lombok.extern.slf4j.Slf4j; | ||
import marquez.service.SearchService; | ||
import marquez.service.ServiceFactory; | ||
import org.opensearch.client.opensearch.core.SearchResponse; | ||
import org.opensearch.client.opensearch.core.search.Hit; | ||
|
||
@Slf4j | ||
@Path("/api/v2beta/search") | ||
public class SearchResource { | ||
|
||
private final SearchService searchService; | ||
|
||
public SearchResource(@NonNull final ServiceFactory serviceFactory) { | ||
this.searchService = serviceFactory.getSearchService(); | ||
} | ||
|
||
@Timed | ||
@ResponseMetered | ||
@ExceptionMetered | ||
@GET | ||
@Produces(APPLICATION_JSON) | ||
@Path("jobs") | ||
public Response searchJobs(@QueryParam("q") @NotBlank String query) throws IOException { | ||
if (searchService.isEnabled()) { | ||
return Response.status(Response.Status.SERVICE_UNAVAILABLE).build(); | ||
} | ||
return formatOpenSearchResponse(this.searchService.searchJobs(query)); | ||
} | ||
|
||
@Timed | ||
@ResponseMetered | ||
@ExceptionMetered | ||
@GET | ||
@Produces(APPLICATION_JSON) | ||
@Path("datasets") | ||
public Response searchDatasets(@QueryParam("q") @NotBlank String query) throws IOException { | ||
if (searchService.isEnabled()) { | ||
return Response.status(Response.Status.SERVICE_UNAVAILABLE).build(); | ||
} | ||
return formatOpenSearchResponse(this.searchService.searchDatasets(query)); | ||
} | ||
|
||
private Response formatOpenSearchResponse(SearchResponse<ObjectNode> response) { | ||
List<ObjectNode> hits = | ||
response.hits().hits().stream().map(Hit::source).collect(Collectors.toList()); | ||
List<Map<String, List<String>>> highlights = | ||
response.hits().hits().stream().map(Hit::highlight).collect(Collectors.toList()); | ||
|
||
return Response.ok(new OpenSearchResult(hits, highlights)).build(); | ||
} | ||
|
||
@ToString | ||
public static final class OpenSearchResult { | ||
@Getter private final List<ObjectNode> hits; | ||
@Getter private final List<Map<String, List<String>>> highlights; | ||
|
||
@JsonCreator | ||
public OpenSearchResult( | ||
@NonNull List<ObjectNode> hits, @NonNull List<Map<String, List<String>>> highlights) { | ||
this.hits = hits; | ||
this.highlights = highlights; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2018-2024 contributors to the Marquez project | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package marquez.search; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Getter; | ||
|
||
public class SearchConfig { | ||
public static final boolean ENABLED = false; | ||
public static final String SCHEME = "http"; | ||
public static final String HOST = "opensearch"; | ||
public static final int PORT = 9200; | ||
public static final String USERNAME = "admin"; | ||
public static final String PASSWORD = "admin"; | ||
|
||
@Getter @JsonProperty private boolean enabled = ENABLED; | ||
|
||
@Getter @JsonProperty private String scheme = SCHEME; | ||
|
||
@Getter @JsonProperty private String host = HOST; | ||
|
||
@Getter @JsonProperty private int port = PORT; | ||
|
||
@Getter @JsonProperty private String username = USERNAME; | ||
|
||
@Getter @JsonProperty private String password = PASSWORD; | ||
} |
Oops, something went wrong.