Forum Discussion

kc's avatar
kc
Ace
11 years ago

API to search user by partial login name?

Want to see if there is any API mechanism to search for user by partial  login name?   http://community.lithium.com/restapi/vc/search/users?q=f http://community.lithium.com/restapi/vc/search/users...
  • DougS's avatar
    11 years ago

    Hi kc,

     

    By default a user search will search the following fields for the search term entered in the q parameter:

     

    *login*

    biography

    name_first

    name_last

    email

    rank_name

     

    You can scope the search to any one of those fields by specifying the field name as the value of th f parameter -- I believe the field you want to search is *login*, so this query should do the trick:

     

    http://community.lithium.com/restapi/vc/search/users?q=(\*login\*:f*)

     

    To make a query that uses a wildcard search, you need to format the value of the q parmameter like a lucene search query.  This should find you all the users with login names that start with the letter 'f' (you should use the field login which is not analyzed instead of the *login* field which is analyzed and will return you words with the letter 'f' anywhere in the login name.  You'll want to include the page_size parameter set to a large size if you expect a large result set for else make multiple search calls with different values for the page parameter):

     

    http://community.lithium.com/restapi/vc/search/users?q=(login:f*)

     

    -Doug