Question & Answer
Question
The documentation for search/facet/cube, which is located at ES_INSTALL_ROOT/docs/api/rest/search/search_facet_cube/api.html, contains a link to an example of the XML response to the API (application/xml). The sample does not explain the structure of the XML file. How do I determine relevant data in the XML response?
Answer
The following sample API call, which applies to content analytic collections that include any type of data source, returns an XML response:
<context-root>/search/facet/cube?collection=sample&facets=[{"namespace":"keyword","id":"$._word.noun","count":10},{"namespace":"keyword","id":"$._word.verb","count":10}]&correlation=facetPairs&query=*:*
To extract relevant data that corresponds to the facet pairs, refer to the following explanation of the XML response to this API call:
<es:countArray> and <es:correlationArray> represents a 2-dimension array.
For example, the response contains the following element:
<es:xxArray>
<es:value>
<es:value>a</es:value>
<es:value>b</es:value>
<es:value>c</es:value>
<es:value>
<es:value>
<es:value>d</es:value>
<es:value>e</es:value>
<es:value>f</es:value>
<es:value>
<es:value>
<es:value>g</es:value>
<es:value>h</es:value>
<es:value>i</es:value>
<es:value>
</es:xxArray>
This element indicates that the second array is:
[i][j] = [ [a , b, c], [d, e, f], [g, h, k] ]
The first dimension, i, represents a rank of facets of the first facet in the facet pair, and the second dimension, j, represents a rank of facets of the second facet.
For example, if the first dimension is "Noun" and the second dimension is "Verb", the facet ranks are as follows:
<ibmsc:facet label="Noun">
<ibmsc:facetValue label="series" />
<ibmsc:facetValue label="film" />
<ibmsc:facetValue label="world" />
</ibmsc:facet>
<ibmsc:facet label="Verb">
<ibmsc:facetValue label="be" />
<ibmsc:facetValue label="write" />
<ibmsc:facetValue label="have" />
</ibmsc:facet>
If the result becomes as follows:
<es:xxArray>
<es:value>
<es:value>a</es:value>
<es:value>b</es:value>
<es:value>c</es:value>
<es:value>
<es:value>
<es:value>d</es:value>
<es:value>e</es:value>
<es:value>f</es:value>
<es:value>
<es:value>
<es:value>g</es:value>
<es:value>h</es:value>
<es:value>i</es:value>
<es:value>
</es:xxArray>
The following results represent the second array:
be write have
series a b c
film d e f
world g h i
Product Synonym
ICA
Was this topic helpful?
Document Information
Modified date:
17 June 2018
UID
swg21614337