开发者

Sphinx over .net MVC

Good time of a day!

I have:

  1. Windows 2008 web server edition with big mvc project
  2. Anoth开发者_开发问答er dedicated MySQL server (Ubuntu Linux) with Sphinx engine installed on it

The task is to build the fast search over the photos database. I have spent to much time to find the working solution of mvc & sphinx with step-by-step instruction, cause im a new in this technoligie.

I want know how to use sphinx with .net mvc

I found 2 client libraries but both are with out any documentations (following this: Sphinx .net implementation) :(

Anybody can help? Thanks a lot!

PS> sorry for my english ;)


As in any sphinx powered app, you have two main tasks:

  1. Define/create your sphinx indexes (sphinx.conf)
  2. Use a (.net) connector to submit your queries

For number 1 check the Sphinx docs, search for mysql and sql_query.

As for 2, you should have something like:

public class MyController : Controller {
  [HttpPost]
  public ActionResult Search() {
    string looking_for = Request.Form["search_item"];
    SphinxClient sphinx_client = new SphinxClient();
    List<Result> results = sphinx_client.Query(looking_for, "my_sphinx_index_name");
    // your view should know what to do with a Result collection
    return View(results);
  }
}

ps: I'm using this .net connector (which I wrote =P) http://dotsphinxclient.codeplex.com/wikipage?title=Getting%20started&referringTitle=Documentation


The better way is to use Mysql .Net connector and communicate with Sphinx via SphinxQL interface.

This way gives you more functionality and you won't need to catch up changes from custom API development.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜