2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.aai.sa.searchdbabstraction.searchapi;
23 import org.radeox.util.logging.Logger;
25 import com.fasterxml.jackson.annotation.JsonProperty;
28 * This class represents the structure of a search statement.
31 * The expected JSON structure to represent a Completion suggest search statement is as follows:
33 * { "suggest-vnf" : { "text" : "VNFs", "completion" : { "field" : "entity_suggest", "size": 1 } } }
35 public class SuggestionStatement {
37 @JsonProperty("results-size")
40 @JsonProperty("suggest-field")
43 @JsonProperty("suggest-text")
46 public Integer getSize() {
50 public void setSize(Integer size) {
54 public String getField() {
58 public void setField(String field) {
62 public String getText() {
66 public void setText(String text) {
71 * This method returns a string which represents this statement in syntax that is understandable
72 * by ElasticSearch and is suitable for inclusion in an ElasticSearch query string.
74 * @return - ElasticSearch syntax string.
76 public String toElasticSearch() {
78 StringBuilder sb = new StringBuilder();
81 sb.append("\"suggest-vnf\": {");
82 sb.append("\"text\": ").append("\"" + text + "\"").append(", ");
83 sb.append("\"completion\": {");
84 sb.append("\"field\": ").append("\"" + field + "\"").append(", ");
85 sb.append("\"size\": ").append(size);
90 Logger.debug("Generated raw ElasticSearch suggest statement: " + sb.toString());