Book Image

Solr Cookbook - Third Edition

By : Rafal Kuc
Book Image

Solr Cookbook - Third Edition

By: Rafal Kuc

Overview of this book

Table of Contents (18 chapters)
Solr Cookbook Third Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Using position increment to divide sentences


Imagine that we want to search in the short notes created by our users. We want to have two possibilities—searching inside a single sentence and searching inside the whole content of the note. We also know that our users don't write notes longer than 100 sentences, and each sentence has a maximum of 100 words, giving us a maximum of 10,000 words per note. To achieve this, we will use position increments that allow us to control how data is divided in the same field.

How to do it...

The following steps will allow us to fulfill our requirements:

  1. We start with example data, which will look like this:

    <add>
     <doc>
      <field name="id">1</field>
      <field name="note_line">Support meeting at Monday.</field>
      <field name="note_line">Need to prepare presentation.</field>
     </doc>
    </add>
  2. Now, we need to create an index structure. To do this, we need to add the fields that will be used. We do this by adding...