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 com.fasterxml.jackson.annotation.JsonProperty;
24 import org.radeox.util.logging.Logger;
27 * This class represents the structure of a search statement.
30 * The expected JSON structure to represent a Completion suggest search statement is as follows:
32 * { "suggest-vnf" : { "text" : "VNFs", "completion" : { "field" : "entity_suggest", "size": 1 } } }
34 public class SuggestionStatement {
36 @JsonProperty("results-size")
39 @JsonProperty("suggest-field")
42 @JsonProperty("suggest-text")
45 public Integer getSize() {
49 public void setSize(Integer size) {
53 public String getField() {
57 public void setField(String field) {
61 public String getText() {
65 public void setText(String text) {
70 * This method returns a string which represents this statement in syntax that is understandable by ElasticSearch
71 * and is suitable for inclusion in an ElasticSearch query string.
73 * @return - ElasticSearch syntax string.
75 public String toElasticSearch() {
77 StringBuilder sb = new StringBuilder();
80 sb.append("\"suggest-vnf\": {");
81 sb.append("\"text\": ").append("\"" + text + "\"").append(", ");
82 sb.append("\"completion\": {");
83 sb.append("\"field\": ").append("\"" + field + "\"").append(", ");
84 sb.append("\"size\": ").append(size);
89 Logger.debug("Generated raw ElasticSearch suggest statement: " + sb.toString());