API v2 create/update template
Dear OpenSearchServer!
I have found an issue, server cannot deserialize json.
Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@147bba9; line: 2, column: 5](through reference chain: com.jaeksoft.searchlib.webservice.query.search.SearchPatternQuery["query"])
I used the provided sample, found in the documentation: http://www.opensearchserver.com/documentation/api_v2/searching_using_fields/template_create_update.md
It is a really important feature, im working on a client program.
I look forward to your responde.
Ansaldos
I found the answer.
I removed 'query' from the json, and works well. So, for example the request body is need to be in this format:
{ "searchFields": [{ "field": "title", "mode": "TERM_AND_PHRASE", "boost": 10.0, "phraseBoost": 10.0 }, { "field": "titleExact", "mode": "TERM_AND_PHRASE", "boost": 10.0, "phraseBoost": 10.0 }, { "field": "titlePhonetic", "mode": "TERM_AND_PHRASE", "boost": 10.0, "phraseBoost": 10.0 }, { "field": "content", "mode": "TERM_AND_PHRASE", "boost": 1.0, "phraseBoost": 1.0 }, { "field": "contentExact", "mode": "TERM_AND_PHRASE", "boost": 1.0, "phraseBoost": 1.0 }, { "field": "contentPhonetic", "mode": "TERM_AND_PHRASE", "boost": 1.0, "phraseBoost": 1.0 }, { "field": "urlSplit", "mode": "TERM_AND_PHRASE", "boost": 5.0, "phraseBoost": 5.0 }, { "field": "urlExact", "mode": "TERM_AND_PHRASE", "boost": 5.0, "phraseBoost": 5.0 }, { "field": "urlPhonetic", "mode": "TERM_AND_PHRASE", "boost": 5.0, "phraseBoost": 5.0 }, { "field": "fileName", "mode": "TERM_AND_PHRASE", "boost": 10.0, "phraseBoost": 10.0 }, { "field": "fileNameExact", "mode": "TERM_AND_PHRASE", "boost": 10.0, "phraseBoost": 10.0 }, { "field": "fileNamePhonetic", "mode": "TERM_AND_PHRASE", "boost": 10.0, "phraseBoost": 10.0 }, { "field": "full", "mode": "TERM_AND_PHRASE", "boost": 0.1, "phraseBoost": 0.1 }, { "field": "fullExact", "mode": "TERM_AND_PHRASE", "boost": 0.1, "phraseBoost": 0.1 }, { "field": "fullPhonetic", "mode": "TERM_AND_PHRASE", "boost": 0.1, "phraseBoost": 0.1 }], "lang": "ENGLISH", "collapsing": { "max": 0, "mode": "OFF", "type": "OPTIMIZED" }, "filterOperator": "AND", "returnedFields": ["url", "fileSystemDate", "fileType", "fileSize"], "snippets": [{ "field": "title", "tag": "b", "separator": "...", "maxSize": 200, "maxNumber": 1, "fragmenter": "NO" }, { "field": "fileName", "tag": "b", "separator": "...", "maxSize": 200, "maxNumber": 1, "fragmenter": "NO" }, { "field": "content", "tag": "b", "separator": "...", "maxSize": 200, "maxNumber": 1, "fragmenter": "SENTENCE" }], "enableLog": false, "start": 0, "rows": 10, "operator": "AND", "emptyReturnsAll": true }
Please update this on the documentation page to help others! I dont close the issue, please close when you updated the documentation.
Hi Ansaldos,
Thanks for the alert. Of course, the JSON should not contains this:
"successful": true
We fix that on the documentation right now.
Your welcome, and thanks for your great work.
Yes, "successful" was the other, but i noticed that dont need. The "query" wasnt that clear.
Let me know when your client will be ready. If you want we can add some links in in the website and some ReadMe.