FacetView2
一个纯 javascript 的 ElasticSearch 搜索索引前端。
它是作为一个 jQuery 插件开发的,可以让你轻松地将一个分面浏览前端嵌入到任何网页中。
FacetView2 是对原 FacetView 应用的重大重写。参见 https://github.com/okfn/facetview 了解以前的版本。
使用 FacetView2
在您的网页上添加以下代码:
<script type="text/javascript" src="vendor/jquery/1.7.1/jquery-1.7.1.min.js"></script> <link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.min.css"> <script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script> <link rel="stylesheet" href="vendor/jquery-ui-1.8.18.custom/jquery-ui-1.8.18.custom.css"> <script type="text/javascript" src="vendor/jquery-ui-1.8.18.custom/jquery-ui-1.8.18.custom.min.js"></script> <script type="text/javascript" src="es.js"></script> <script type="text/javascript" src="bootstrap2.facetview.theme.js"></script> <script type="text/javascript" src="jquery.facetview2.js"></script> <link rel="stylesheet" href="css/facetview.css">
然后在页面的某个地方添加一个脚本,在特定的页面元素上实际调用并设置 facetview:
<script type="text/javascript"> jQuery(document).ready(function($) { $('.facet-view-simple').facetview({ search_url: 'http://localhost:9200/myindex/type/_search', facets: [ {'field': 'publisher.exact', 'size': 100, 'order':'term', 'display': 'Publisher'}, {'field': 'author.name.exact', 'display': 'author'}, {'field': 'year.exact', 'display': 'year'} ], }); }); </script>
定制化
FacetView2 已经被编写成允许在一个灵活但受限的页面框架内进行广泛的定制。
这里会有更多的文档来介绍如何做到这一点,但在这段时间里,可以看看 jquery.facetview.js 的源码,看看配置选项和模板,可以替换为自定义显示。
版权和许可
Copyright 2014 Cottage Labs.
根据 MIT 许可证授权
twitter bootstrap: http://twitter.github.com/bootstrap/ MIT License: http://www.opensource.org/licenses/mit-license.php