regex - Solr RegexTransformer only delviers first match to multivalued field -
i want find hashtags in comment coming db. use regextransformer of solr multivalued field. problem is, transformer delivers first match of string , not matches.
boards.xml: <field column="hashtag" sourcecolname="comment" regex="(#[^.!\s]+)" />
schema.xml: <field name="hashtag" type="string" multivalued="true" />
so e.g. "this #good #comment" input should save #good , #comment in multivalued field, #good arrives.
i know not best when comes regex, according http://www.regexplanet.com should work intended.
ok, found out, behaviour purpose. returns 1 match. solved problem using scripttransformer
function commentpieces(row){ var reg = new regexp(/(#[^.!\s]+)/g); var arr = new java.util.arraylist(); while((result = reg.exec(row.get('comment'))) !== null) { if(!arr.contains(result[0])){ arr.add(result[0]); } } row.put('hashtag', arr); return row; }
Comments
Post a Comment