X

Geertjan's Blog

  • July 18, 2008

Quick Search API Sample

Geertjan Wielenga
Product Manager
I noticed in recent builds that the appearance of the new 6.5 Quick Search feature has improved recently. It looks a lot better and provides more functionality. First, you can see in the final category below that there is a "..." elipsis if the list of results is longer than the length of the visible list:

So you can click on that elipsis and see all the results. Also, if you're looking at the screenshot above and wondering: "He typed 'tip' but several of the results do NOT have 'tip' in the title," then you should look at this screenshot:

Here you can see that the search string "lookup" is in NONE of the returned titles. However, I happen to know for a fact that "lookup" is mentioned in the content of each of the above items, which means that the search does more than a title search, it actually looks into the body of the help topics, which is great news.

Finally, the categories are shown like this, so that you can limit the search to the category of your choice:

And maybe you're wondering about the categories "User FAQs" and "NetBeans Zone" in the screenshots above? Those come from the sample I'm turning into a tutorial describing the API that makes the above integrations possible. It is to be called "Quick Search Integration Tutorial" and will hopefully be available at the beginning of next week. However, the sample code is already available in the Plugin Portal:

http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=11179

Remember that you'll need a recent 6.5 build (Milestone 1 should be fine, I think) if you want to play with the sample.

Join the discussion

Comments ( 8 )
  • Alexander Friday, June 4, 2010

    Dear Geertjan, how to use quick search panel in a custom form. For example I have a list of clients, and a JPanel (on TopComponent) with a TextField named "Client". I want to equip this field or replace it with a field like in quick search.


  • Ingemar Skelander Friday, April 5, 2013

    Hello Geertjan. I'm having some problems with my implementation of this API. I got the searchprovider set up correctly and the application searches beutifully amongst my customers and articles.

    But.

    When the search has found a article, for example, I have a action that opens that article in my articleeditor. When i open the article, the quicksearch textfield says, "( no results )", in evil red text.

    Do you have any idea of why this is?


  • guest Saturday, April 13, 2013

    Got the same "no results" error issue though the search found a few results. Any insight will be much appreciated. Cheers.


  • Geertjan Saturday, April 13, 2013

    You're saying that you followed this tutorial?

    https://platform.netbeans.org/tutorials/nbm-quick-search.html


  • Geertjan Saturday, April 13, 2013

    Tried it in NetBeans Platform 7.3. Works perfectly. So if you're not going to provide code showing the problem, I'm not going to be able to help.


  • Ingemar Skelander Monday, April 15, 2013

    Hello again Geertjan. I will provide some sample code of the SearchProvider.

    public class ArticleSearchProvider implements SearchProvider {

    @Override

    public void evaluate(SearchRequest request, SearchResponse response)

    {

    List<Article> allArticles = findAllArticles() // not the real call

    List<Article> viableResults = new ArrayList<Article>();

    for (Article article : articles) {

    if (isCompatibleId(article, request)) {

    viableResults.add(article);

    } else if (isCompatibleName(article, request)) {

    viableResults.add(article);

    } else if (isCompatiblePrice(article, request)) {

    viableResults.add(article);

    }

    }

    for (Article article : viableResults) {

    ArticleAction articleAction

    = new ArticleAction(viableResults, article);

    if(!response.addResult(articleAction, article.getName() + " " +

    article.getNumber())) {

    return;

    }

    }

    }

    }

    and the Runnable, ArticleAction, just posts the selected article to the global lookup where it is processed and the articleeditor opens with the selected article.

    Sorry that the formatting of the code is kinda messed up.


  • Geertjan Monday, April 15, 2013

    Just answer the question, please. Did you follow the tutorial? Ignoring your comments until you answer the question. Also, just join the dev mailing list and ask your questions there.


  • Ingemar Skelander Monday, April 15, 2013

    Sorry, I forgot to answer the tutorial question. Yes I followed the tutorial. I will join the mailing list, so no point in continuing here.

    Thanks.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha