Hi Reto,
On 04/05/2012 04:54 PM, Reto Bachmann-Gmür wrote:
> Thanks Suat,
>
> With your help I could implement the support to go one level deeper.
>
> The corresponding webdav class is here:
>
> http://svn.apache.org/viewvc/incubator/stanbol/branches/ontonet-showcase/featured-vfolders/src/main/java/org/apache/stanbol/contenthub/vfolders/CountResource.java?view=log
>
> So one can now mount the webdavshare, go into the category (e.g. places)
> select an entry (e.g. Switzerland). I don't know how to get the next level
> which should be
> - the matching content items
> - and again the categories as in the root folder but only for categories
> that contain entry that help reducing the matching set (to a proper but
> non-empty subset)
"SolrQueryUtil.prepareFacetedSolrQuery" method is used to construct a
SolrQuery. But, it requires additional parameters other than the
original query term.
1) allAvailableFacets: This can be obtained through:
featuredSearch.getAllFacetResults();
2) constraints: This is a map like Map<String, List<Object>>. You should
populate keys of this map with the facet names (i.e directory names).
Corresponding List<Object> should be filled with intended facet values
to filter results. This can be done during the traversal of facet
results obtained in the SearchResult object.
So, the code looks like the one below. I hope it clarifies the usage.
SearchResult allResults = featuredSearch.search("*:*");
Map<String, List<Object> constraints;
//initialize constraints using facet results return in allResults object
SolrQuery query = SolrQueryUtil.prepareFacetedSolrQuery("*:*,
featuredSearch.getAllFacetResults(), constraints);
SearchResult filteredResults = featuredSearch.search(query);
//get the matching documents with provided constraints
List<DocumentResult> documents = filteredResults.getDocuments();
> I think webdav access should be identical to the web access to faceted
> search with the exception that one can only remove filters in the inverse
> order of adding them. The idea is to have a simple demo of the webdav
> capabilities so that more virtual folders can be added providing a user
> friendly way to access stanbol.
AFAIU, directories correspond with the facet names e.g places as you
mentioned earlier. So, when one goes into the places folder, he will see
the documents having an associated places field. Also, he will see other
folders corresponding to values regarding with places facet. If so, I
also think this is a nice alternative to navigate on documents.
> Another issue is that one can start featuredSearch only with a full-text
> query, for webdav one should be browsing the whole set of content items,
> but I think searching for "a*" is good enough to get started.
*:* seems to work. Could you please try this one?
> To install the current version you need to check out and install on your
> stanbol instance:
> -
> http://svn.apache.org/repos/asf/incubator/stanbol/branches/ontonet-showcase/webdav/
> -
> http://svn.apache.org/repos/asf/incubator/stanbol/branches/ontonet-showcase/featured-vfolders/
I couldn't compile branches as there is a problem when downloading
milton related dependencies.
> After that you can mount http://localhost:8080/vfolders/ with webdav.
>
> Would be great if you could help me getting one level deeper. As it is only
> a subset of the functionality accessible with the webbrowser I hope this
> code can be accessed, and that this can abstract away the assembling of
> query string. For now I see now need for range-queries with the webdav
> access.
See above code snippet.
Best,
Suat
> Cheers,
> Reto
>
>
> On Thu, Apr 5, 2012 at 2:17 PM, Suat Gonul <[email protected]> wrote:
>
>> Hi Reto,
>>
>> You can use the featured search by constructing a SolrQuery using the
>> facet names and values as in the following example:
>>
>> SolrQuery query = new SolrQuery();
>> query.setQuery("a*");
>> query.addFilterQuery(<facetName> + ":"+
>> ClientUtils.escapeQueryChars(<facetValue>));
>> featuredSearch.search(query);
>>
>>
>> You can obtain facet values by:
>>
>> for (Count count : facetResult.getFacetField().getValues()) {
>> String facetValue = count.getName();
>> long documentCount = count.getCount();
>> }
>>
>>
>> Based on the types of results facets e.g int, double, date, etc. you can
>> write range queries. Type of a facet can be obtained by:
>>
>> facetResult.getType();
>>
>>
>> You can have a look at solr query syntax for range queries at [1].
>>
>> Best,
>> Suat
>>
>> [1] http://wiki.apache.org/solr/SolrQuerySyntax
>>
>>
>> On 04/05/2012 01:14 PM, Reto Bachmann-Gmür wrote:
>>> Hello
>>>
>>> I'm trying to programmatically access the facetted browsing features. I
>> got
>>> the first step, getting the top level categories with:
>>>
>>> SearchResult searchResult = featuredSearch.search("a*");
>>> List<FacetResult> facetResults = searchResult.getFacets();
>>> for (FacetResult fr : facetResults) {
>>> final String name = fr.getFacetField().getName();
>>> System.out.println("name: "+name);
>>> }
>>>
>>> How do I get the faceted search entries in the enumerated categories, and
>>> how do I apply such an entry, how do I get the matching content items?
>>>
>>> Cheers,
>>> Reto
>>>
>>