How to use facet query in CollapsingQParserPlugin in solr? - solr4

I want to generate facets on the uncollapsed set for a particular facet. Is there any solr query to achieve these functionality?

This can be easily achieved by tagging the collapse filter, and then excluding the that tag in the particular facet. Say you want to collapse by group and facet on widget, then you could do:
?q=*:*
&fq={!collapse field=group tag=collapse}
&facet=true
&facet.field={!ex=collapse}widget

Related

Using #query on CrudRepository(Spring data jdbc) with table join

I am trying spring data jdbc with #query and I met a question: If I have a query that joins 2
tables like this:
#Query("select a.*, b.* from master a, detail b where b.master_id=a.id and a.id=:id")
How do I get the response?
The official Spring Data JDBC, References, and Aggregates didn't give any hint on it.
Any suggestion?
You have multiple options:
Use the default RowMapper
Use as the return type a class (or a collection of that class) that has properties for all the fields you are selecting.
This will return a single element for each row.
Since you are referring to the two tables as master and detail you probably don't want that in this case.
Use a custom RowMapper
The #Query annotation allows you to specify your own rowMapperClass which will get instantiated and passed to a NamedParameterJdbcTemplate together with your query.
Again this will result in on result element per row selected and therefore probably isn't what you want.
Use a custom ResultSetExtractor
This can be again specified in the #Query annotation.
And allows you to construct the result in an arbitrary way.
See the documentation for ResultSetExtractor for more details.
Remark: If you are using a ResultSetExtractor to create a single Master with multiple Detail instances from multiple rows of your query result make sure to add an ORDER BY master.id. Otherwise the order of rows is likely as desired but actually not guaranteed.

TFS query to show all tasks by assignee

I'm trying to create a view in TFS where I can see all tasks for the current Sprint by assignee. Preferably be able to expand and collapse each Assignee's section to reduce vertical scrolling. I don't see a way to create a Tree query with the Assignee Name as the parent and the tasks as children. It looks like the basis is always a Story. Is there a way to do this?
I know I can look at the Board view and filter by assignee but, that's a lot of clicks and scrolling.
You can create a chart for your query. This will allow you to break the query down into assignees.
There is no group by option in Work Item Queries.
You can only 'group by' work item type in tree and relation based queries. You'll need to resort to Excel to do the filtering or use PowerBI.

ruby on rails sunspot solr search show some specific results on top

I'm using Sunspot Solr for indexing and searching in our Rails application
search = Product.search do
with(:categoery, [1,2,3])
order_by(:priority)
#and some other filters
end
But for some specific Users i want to display some product with id suppose [8,9] ordered on-top of search result and then other products(as i don't want to discard other results), is it possible in same search query?
Have a look at the Query Elevation Component :
The Query Elevation Component lets you configure the top results for a
given query regardless of the normal Lucene scoring. This is sometimes
called "sponsored search," "editorial boosting," or "best bets." This
component matches the user query text to a configured map of top
results.
The text can be any string or non-string IDs, as long as it's indexed.
Although this component will work with any QueryParser, it makes the
most sense to use with DisMax or eDisMax.
The Query Elevation Component is supported by distributed searching.

Visual studio online query items without tags

When are working with various Work Item types (user stories,Tasks, etc) we assign tags to reference the area of work. This makes it easy to filter the Backlogs items view to find any related stories.
I would like to build a query to identify Work Items where the tags have not yet been assigned.
I know this can be achieved using excel and filtering, however I specifically would like to do this using the queries. Is this possible??
Thanks in advance for any assistance.
Firstly, I have to say that it is not possible to create work item query to show work items which don't contain tags. As you see that the Operator for Tags is Contains or Does Not Contain, it is not possible to use these two operators to filter out these non-tagged work items.
Secondly, as you have more than 100 tags, it is not an effective way to use "Does Not Contain" operator to exclude all tagged work items.
So,
How about you adding a 'Null' tag to all non-tagged work items to specify that these work items don't have any tags? With this approach, you can create a work item query with Tags Contains Null to list these non-tagged work items.
If you don't want to take this approach, you need to work with excel just as you mentioned above, or take Dave's advice to work with API.

How would you sort an array in Ruby based off of a formula (e.g. search ranking)?

So, I'm building quick and dirty search functionality in my first rails app. I'm doing a query and returning a list of objects. e.g.
#articles = Article.find_by_sql("select * from article where title like "%test%" or title like "%foobar%")
So, the articles collection will return a lot of data, some of it matching my search terms better than others. I want to sort the array so that the items that match are presented first.
Here's the conceptual pseudo code I'm trying to implement.
for each article in #articles
calculate the article score based on how many times the search terms appear
sort the array of articles based on the score
("score" is not part of the article object.)
Any ideas on how this can be sorted?
If all else fails you can do:
#articles.sort! {|x,y| search_fitness_function(y) <=> search_fitness_function(x)}
Depending on what database you're using it might be more efficient to complete the ranking there. For instance, in MySQL you could you Natural Language Full Text Search:
http://dev.mysql.com/doc/refman/5.1/en/fulltext-natural-language.html
By default or with the IN NATURAL
LANGUAGE MODE modifier, the MATCH()
function performs a natural language
search for a string against a text
collection. A collection is a set of
one or more columns included in a
FULLTEXT index. The search string is
given as the argument to AGAINST().
For each row in the table, MATCH()
returns a relevance value; that is, a
similarity measure between the search
string and the text in that row in the
columns named in the MATCH() list.

Resources