I am pretty new to TypeScript and especially to the custom Palantir implementation for Object(Sets). What I am trying to archive: I'd like to filter an ObjectSet down to some specific values. Then I'd like to return the first of these values. In fact I'd just like to return a single line. What I've done so far:
@Function()
public nextUnprocessedValueString(inputObject: ObjectSet<CombinedSentencesForTagging>): ObjectSet<CombinedSentencesForTagging>{
const result = Objects.search().combinedSentencesForTagging().filter(f => f.customerFeedback.exactMatch('i like it very much.'))
return result
What I would need is only the first line (or a random line).
Thanks!
Give this a try:
@Function()
public nextUnprocessedValueString(inputObject: ObjectSet<CombinedSentencesForTagging>): CombinedSentencesForTagging {
const result =
inputObject.filter(f => f.customerFeedback.exactMatch('i like it very much.'))
.orderBy(f => f.customerFeedback.asc())
.take(1);
return result[0];
}
Here are the changes I made to the original function:
CombinedSentencesForTagging
object.filter
line to run on the inputObject
specified in the function's parametersorderBy
and take
filter clauses to pick just one of the filtered results.