- // Generate our audit log.
- auditLogger.info(SearchDbMsgs.PROCESS_REST_REQUEST,
- new LogFields()
- .setField(LogLine.DefinedFields.RESPONSE_CODE, response.getStatusCodeValue())
- .setField(LogLine.DefinedFields.RESPONSE_DESCRIPTION,
- response.getStatusCode ().getReasonPhrase()),
- (request != null) ? request.getMethod().toString () : "Unknown",
- (request != null) ? request.getRequestURL ().toString () : "Unknown",
- (request != null) ? request.getRemoteHost () : "Unknown",
- Integer.toString(response.getStatusCodeValue()));
-
- // Clear the MDC context so that no other transaction inadvertently
- // uses our transaction id.
- ApiUtils.clearMdcContext();
-
- return response;
- }
-
-
- /**
- * This method takes a JSON format document schema and produces a set of
- * field mappings in the form that Elastic Search expects.
- *
- * @param documentSchema - A document schema expressed as a JSON string.
- * @return - A JSON string expressing an Elastic Search mapping configuration.
- * @throws com.fasterxml.jackson.core.JsonParseException
- * @throws com.fasterxml.jackson.databind.JsonMappingException
- * @throws IOException
- */
- public String generateDocumentMappings(String documentSchema)
- throws com.fasterxml.jackson.core.JsonParseException,
- com.fasterxml.jackson.databind.JsonMappingException, IOException {
-
- // Unmarshal the json content into a document schema object.
- ObjectMapper mapper = new ObjectMapper();
- DocumentSchema schema = mapper.readValue(documentSchema, DocumentSchema.class);
-
- // Now, generate the Elastic Search mapping json and return it.
- StringBuilder sb = new StringBuilder();
- sb.append("{");
- sb.append("\"properties\": {");
-
- boolean first = true;
- for (DocumentFieldSchema field : schema.getFields()) {
-
- if (!first) {
- sb.append(",");
- } else {
- first = false;
- }
-
- sb.append("\"").append(field.getName()).append("\": {");
-
- // The field type is mandatory.
- sb.append("\"type\": \"").append(field.getDataType()).append("\"");
-
- // If the index field was specified, then append it.
- if (field.getSearchable() != null) {
- sb.append(", \"index\": \"").append(field.getSearchable()
- ? "analyzed" : "not_analyzed").append("\"");
- }
-
- // If a search analyzer was specified, then append it.
- if (field.getSearchAnalyzer() != null) {
- sb.append(", \"search_analyzer\": \"").append(field.getSearchAnalyzer()).append("\"");
- }
-
- // If an indexing analyzer was specified, then append it.
- if (field.getIndexAnalyzer() != null) {
- sb.append(", \"analyzer\": \"").append(field.getIndexAnalyzer()).append("\"");
- } else {
- sb.append(", \"analyzer\": \"").append("whitespace").append("\"");
- }
-
- sb.append("}");
+
+ /**
+ * This method takes a JSON format document schema and produces a set of field mappings in the form that Elastic
+ * Search expects.
+ *
+ * @param documentSchema - A document schema expressed as a JSON string.
+ * @return - A JSON string expressing an Elastic Search mapping configuration.
+ * @throws com.fasterxml.jackson.core.JsonParseException
+ * @throws com.fasterxml.jackson.databind.JsonMappingException
+ * @throws IOException
+ */
+ public String generateDocumentMappings(String documentSchema) throws com.fasterxml.jackson.core.JsonParseException,
+ com.fasterxml.jackson.databind.JsonMappingException, IOException {
+
+ // Unmarshal the json content into a document schema object.
+ ObjectMapper mapper = new ObjectMapper();
+ DocumentSchema schema = mapper.readValue(documentSchema, DocumentSchema.class);
+
+ // Now, generate the Elastic Search mapping json and return it.
+ StringBuilder sb = new StringBuilder();
+ sb.append("{");
+ sb.append("\"properties\": {");
+
+ boolean first = true;
+ for (DocumentFieldSchema field : schema.getFields()) {
+
+ if (!first) {
+ sb.append(",");
+ } else {
+ first = false;
+ }
+
+ sb.append("\"").append(field.getName()).append("\": {");
+
+ // The field type is mandatory.
+ sb.append("\"type\": \"").append(field.getDataType()).append("\"");
+
+ // If the index field was specified, then append it.
+ if (field.getSearchable() != null) {
+ sb.append(", \"index\": \"").append(field.getSearchable() ? "analyzed" : "not_analyzed").append("\"");
+ }
+
+ // If a search analyzer was specified, then append it.
+ if (field.getSearchAnalyzer() != null) {
+ sb.append(", \"search_analyzer\": \"").append(field.getSearchAnalyzer()).append("\"");
+ }
+
+ // If an indexing analyzer was specified, then append it.
+ if (field.getIndexAnalyzer() != null) {
+ sb.append(", \"analyzer\": \"").append(field.getIndexAnalyzer()).append("\"");
+ } else {
+ sb.append(", \"analyzer\": \"").append("whitespace").append("\"");
+ }
+
+ sb.append("}");
+ }
+
+ sb.append("}");
+ sb.append("}");
+
+ logger.debug("Generated document mappings: " + sb.toString());
+
+ return sb.toString();