设为首页 收藏本站
查看: 1022|回复: 0

[经验分享] Solr: Indexing 1

[复制链接]

尚未签到

发表于 2016-12-14 11:17:58 | 显示全部楼层 |阅读模式
  
DSC0000.png
At a high level, the Solr indexing process distills down to three key tasks: 


  • Convert a document from its native format into a format supported by Solr,such as XML or JSON.
  • Add the document to Solr using one of several well-defined interfaces, typically HTTP POST.
  • Configure Solr to apply transformations to the text in the document during indexing.
  Solr supports several formats for indexing your document, including XML, JSON,and CSV.
  
DSC0001.png
 
  
DSC0002.png
 
  ------------------------------------------------------------------------------------------------------------------------------------
Designing your schema

  Specifically, you’ll learn to answer the following key questions about your search application:


  • What is a document in your index?
  • How is each document uniquely identified?
  • What fields in your documents can be searched by users?
  • Which fields should be displayed to users in the search results?
  Document granularity
  Determining what a document should represent in your Solr index drives the entire schema-design process. In some cases it’s obvious, such as with our tweet example; the text content is typically short, so each tweet will be a document. But if the content you want to index is large, such as a technical computer book, you may want to treat subsections of a large document as the indexed unit. The key is to think about what your users will want to see in the search results.
  
DSC0003.png
 
  Unique key
  Solr doesn’t require a unique identifier for each document, but if one is supplied, Solr uses it to avoid duplicating documents in your index. If a document with the same unique key is added to the index, Solr overwrites the existing record with the latest document.
  Indexed fields
The best way to think about indexed fields is to ask whether a typical user could develop a meaningful query using that field. Another way to decide if a field should be indexed is to determine if your users would miss it if you did not provide it as a queryable option in your search form.
  In addition to enabling searching, you will also need to mark your field as indexed if you need to sort, facet, group by, provide query suggestions for, or execute function queries on values within a field.
  
Determining which fields to include in the index is specific to every search application.
  Stored fields
Although users probably won’t search by editor name to find a book to read, we may  still want to display the editor’s name in the search results. In general, your documents may contain fields that aren’t useful from a search perspective but are still useful for displaying search results. In Solr, these are called stored fields.
Of course, a field may be indexed and stored, which can be searched and displayed in results.
  ----------------------------------------------------------------------------------------------------------------------------
schema.xml

  
DSC0004.png
 
DSC0005.png
 ------------------------------------------------------------------------------------------------------------------------------------
Defining fields in schema.xml

  Required field attributes

<field name="screen_name"
type="string"
indexed="true"
stored="true" />
   Multivalued fields
  In Solr, fields that can have more than one value per document are called multivalued fields.

<field name="link"
type="string"
indexed="true"
stored="true"
multiValued="true"/>
 
DSC0006.png
   Dynamic fields
  In Solr, dynamic fields allow you to apply the same definition to any fields in your documents whose names match either a prefix or suffix pattern, such as s_* or *_s. Dynamic fields use a special naming scheme to apply the same field definition to any fields that match this kind of glob-style pattern. Dynamic fields help address common problems that occur when building search applications, including


  • Modeling documents with many fields
  • Supporting documents from diverse sources
  • Adding new document sources
  Copy fields
  In Solr, copy fields allow you to populate one field from one or more other fields. Specifically, copy fields support two use cases that are common in most search applications:



  • Populate a single catch-all field with the contents of multiple fields.   In most search applications, users are presented with a single search box in which to enter a query. The intent of this approach is to help your users quickly find documents without having to fill out a complicated form; think about how successful a simple search box has been for Google.
    DSC0007.png
     
    DSC0008.png
     

  • Apply different text analysis to the same field content to create a new searchable field.     Solr copy fields give you the flexibility to enable or disable certain text-analysis features like stemming without having to duplicate storage in your index.
  Unique key field
  If you provide a unique identifier field for each of your documents, Solr will avoid creating duplicates during indexing. In addition, if you plan to distribute your Solr index across multiple servers, you must provide a unique identifier for your documents.

<uniqueKey>id</uniqueKey>
  One thing to note is that it’s best to use a primitive field type, such as string or long, for the field you indicate as being the <uniqueKey/> as that ensures Solr doesn’t make any changes to the value during indexing.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-314242-1-1.html 上篇帖子: Apache Solr Tutorial 下篇帖子: solr in Action 中文2.0 了解Solr
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表