Friday, September 15, 2017

Custom text faceting with booleans cheat sheet



Search Criteria (up to Open Refine 2.8)
Custom text facet
Facet on strings that have both <string one> and <string two>
and (value.contains("<string one>"), value.contains("<string two>"))
Facet on strings that have either <string one> or <string two>
or (value.contains("<string one>"), value.contains("<string two>"))
Facet on strings that have <string one> and <string two> and <string three>
and(value.contains("<string one>"), value.contains("<string two>"), value.contains("<string three>"))

Note: You can chain as many value.contains() statements as you want.
Facet on strings that have <string one> or <string two> or <string three>
or(value.contains("<string one>"), value.contains("<string two>"), value.contains("<string three>"))

Note: You can chain as many value.contains() statements as you want.
Facet on strings that don’t contain <string one>
not(value.contains("<string one>")
Facet on strings that don’t contain <string one> or <string two>
not(or (value.contains("<string one>"), value.contains("<string two>")))
Facet on strings that contain (<string one> and <string two>) or <string 3>
or(and (value.contains("<string one>"), value.contains("<string two>")), value.contains("<string three>") )
regex search : Facet on strings that contain "Playstation" or "PlayStation" or "Nintendo"
or(isNotNull(value.match(/.*Play[sS]tation.*/)), value.contains("Nintendo"))

Search Criteria (Open Refine 3.0)
Custom text facet
Facet on strings that have both <string one> and <string two>
toString(and (value.contains("<string one>"), value.contains("<string two>")))
Facet on strings that have either <string one> or <string two>
toString(or (value.contains("<string one>"), value.contains("<string two>")))
Facet on strings that have <string one> and <string two> and <string three>
toString(and(value.contains("<string one>"), value.contains("<string two>"), value.contains("<string three>")))

Note: You can chain as many value.contains() statements as you want.
Facet on strings that have <string one> or <string two> or <string three>
toString(or(value.contains("<string one>"), value.contains("<string two>"), value.contains("<string three>")))

Note: You can chain as many value.contains() statements as you want.
Facet on strings that don’t contain <string one>
toString(not(value.contains("<string one>"))
Facet on strings that don’t contain <string one> or <string two>
toString(not(or (value.contains("<string one>"), value.contains("<string two>"))))
Facet on strings that contain (<string one> and <string two>) or <string 3>
toString(or(and (value.contains("<string one>"), value.contains("<string two>")), value.contains("<string three>") ))
regex search : Facet on strings that contain "Playstation" or "PlayStation" or "Nintendo"
toString(or(isNotNull(value.match(/.*Play[sS]tation.*/)), value.contains("Nintendo")))

No comments: