Page tree
Skip to end of metadata
Go to start of metadata

The Concat  field expression lets us concatenate the values of two or more stored fields into a single string.  For instance, the following examples take Factbook Olympic Medal search results and concatenate the number of gold medals with the number of silver medals, into a new field called "Gold, Silver:". Note the use of a string constant in the FieldExpression array to force ", " into the concatenation.

Example:

QueryRequest request = new QueryRequest("*:*)");
request.addField(new Concat(new StoredField("gold_i"), new ConstantExpression(", "), new StoredField("silver_i")).as("Gold, Silver:"));
// ... (Perform Search)

REST Syntax:

CONCAT(FIELDEXPRESSION1, FIELDEXPRESSION2...) AS ALIAS

  • FIELDEXPRESSION1 - First field to be concatenated.
  • FIELDEXPRESSION2 - Second field to be concatenated.
  • ALIAS - New field name for the resulting value.

Example:

&fields=CONCAT("gold_i",STRING(", "),"silver_i") as "Gold, Silver:"
  • No labels