The DateExtract field expression extracts information from a date value and stores it in a new field. For instance, the following examples take dates from Factbook RSS news articles and create a new field converting the date into a (numeric) day of the week. ("1" is Monday.)
Available Functions (See here ):
- DAYOFMONTH
- DAYOFWEEK
- DAYOFYEAR
- HOUR
- MINUTE
- MONTH
- QUARTER
- SECOND
- WEEK
- YEAR
Example:
QueryRequest request = new QueryRequest("*:*)"); FieldExtract day_number = new DateExtract(CalendarField.DAYOFWEEK,new StoredField("date")); day_number.setAlias("Weekday"); request.addField(day_number); // ... (Perform Search)
REST Syntax:
FUNCTIONNAME(FIELDEXPRESSION) AS ALIAS
- FUNCTIONNAME - any of the available date extraction functions listed above
- FIELDEXPRESSION - The stored field that contains the date.
- ALIAS - New field name for the result of the function.
Example:
&fields=DAYOFWEEK("date") AS "Weekday"