Hi Damith,

If the "roles" field contains comma separated values, you can simply search
for the specific role using the following query

"roles : role1"


Lucene has an analysis process which takes place before indexing. So the
field values will be tokenized into terms(Text fields are split removing
special characters) , stop words.. etc. In your case, the whole string
"role1, role2, role3" will be tokenized into "role1", "role2" and "role3".
So you can perform a usual search query as I mentioned above.

On Thu, Mar 24, 2016 at 11:35 AM, Damith Wickramasinghe <dami...@wso2.com>
wrote:

> Hi all,
>
> I have a column which contains roles as a comma separated string. eg:-
> role1,role2,role3
>
> I need to find records which matches to specific role. As I checked theres
> no String contains function. But there is wildcard support[1]. To be able
> to work for my usecase wildcard should be of type *role1*. But leading wild
> cards are not supported. But as per the [2] Lucene 2.1, they can be
> enabled by calling QueryParser.setAllowLeadingWildcard( true ). May I
> know whether there is a configuration in DAS to enable this. Also even this
> can be achieved I think this will be an expensive operation. If so is there
> a best way to achieve this? eg:-custom UDF
>
> [1]http://www.lucenetutorial.com/lucene-query-syntax.html
> [2]https://wiki.apache.org/lucene-java/LuceneFAQ
>
> Thanks,
> Damith.
>
> --
> Software Engineer
> WSO2 Inc.; http://wso2.com
> <http://www.google.com/url?q=http%3A%2F%2Fwso2.com&sa=D&sntz=1&usg=AFQjCNEZvyc0uMD1HhBaEGCBxs6e9fBObg>
> lean.enterprise.middleware
>
> mobile: *+94728671315 <%2B94728671315>*
>
>


-- 
Gimantha Bandara
Software Engineer
WSO2. Inc : http://wso2.com
Mobile : +94714961919
_______________________________________________
Architecture mailing list
Architecture@wso2.org
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to