OK, here is how you can proceed.
Create webscript which accept various parameter based on which you want to make search.
It will be java based webscript.
Prepare you search query "Lucene" or "XPath" from the parameter passed.
In webscript java controller you can have access to all alfresco core services like "Searchservice",
"NodeService" etc.. with the help of which you can fire query in repo.
It will return you result set which contains list of result nodeRefs.
You can extract required information from that and return as webscript response.
In you webapplication either you can call above webscript either via AJAX or in some back end java class of your application.
Hope things are clear to you.