Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Indexing in Solr Server

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 544
    Comment on it

    Indexing:

    Solr gives you a quick response and results because of indexing. What does this mean? It means that it searches index instead of the text to retrieve the results for you.

    In book , you search for the index in the index page of the book and not for the keyword in each page of the book. From the index page you can find out the page where the keyword is located.

    Solr also works in the same way, it stores the index, and while searching it searches for the documents matching the index and retrieves the results.

    In Solr, data is represented in the form of documents which contains fields.

    First, we define fields in schema.xml file

    <fields>
      <field name="id" type="string" indexed="true" stored="true" required="true" />
      <field name="name" type="string" indexed="true" stored="true"/>
      <field name="email" type="text_general" indexed="true" stored="true"/>
    </fields>

    Then we create a file which contains our documents and fields:

    Example: demo.xml

    <?xml version="1.0"?>
    <add>
      <doc>    
        <field name="name">John</field>
        <field name="email">john@gmail.com</field>
      </doc>
      <doc>    
        <field name="name">Chris</field>
        <field name="email">chris@gmail.com</field>
      </doc>
      <doc>    
        <field name="name">Roth</field>
        <field name="email">roth@gmail.com</field>
      </doc>
    </add>

    We have defined the fields and indexed them as well in the configuration file.

    Now for indexing this to solr we need to write the following in the command prompt:

    /solr-5.4.1$ java -Durl=http://localhost:8983/solr/[collection-name]/update -jar /solr-5.4.1/example/exampledocs/post.jar [file-name].xml
    
    

    Let suppose we have collection with the name as example and our file name is demo.xml so we'll run the following command:

    /solr-5.4.1$ java -Durl=http://localhost:8983/solr/example/update -jar /solr-5.4.1/example/exampledocs/post.jar demo.xml
    

    This will index our file in the solr server and we can perform search in our documents.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: