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

The SubString  field expression lets us cut a sub-string out of a field value.  The parameters are the field, the starting position (the offset), and the length of the substring.  For instance, the following examples take Factbook news article search results and truncate the text field to a length of 30 characters, placing the result into a new field called "Memo:".


QueryRequest request = new QueryRequest("*:*)");
request.addField(new SubString(new StoredField("text"),0,30,"Memo"));
// ... (Perform Search)

Note that the offset can be negative, meaning that the starting position is counted from the end of the string rather than the beginning.

REST Syntax:


  • FIELDEXPRESSION - The stored field to operate on.
  • START - Beginning of substring.
  • LENGTH - Length of substring.
  • ALIAS - New field name for the resulting value.


&fields=SUBSTRING("text",0,30) as "Memo"
  • No labels