solr-5.3.1 Study (i)

Source: Internet
Author: User
Tags solr

I. Building SOLR Services (standalone) simple, three-step solution
1. Download solr-5.3.1.tgz, unzip the file
2. Create a folder under the./SOLR-5.3.1/SERVER/SOLR directory as a place to store the core
3. Copy the Conf under the./solr-5.3.1/server/solr/configsets/sample_techproducts_configs/to the folder under the second step.
Start SOLR on the go ...

two. SOLR configuration file Schame.xml Learning
1.field
Name:mandatory-the name for the field
Type:mandatory-the Name of a field type from the <types> fieldtype section
Indexed:true If this field should is indexed (searchable or sortable)
Stored:true If this field should is retrievable
Docvalues:true If this field should has doc values. Doc values is useful for faceting, grouping,
Sorting and function queries. Although not required, doc values would make the index
Faster to load, more nrt-friendly and more memory-efficient. They however come with some
Limitations:they is currently only supported by Strfield, Uuidfield and all Trie*fields,
And depending on the field type, they might require the field to being single-valued, be
Required or has a default value (check the documentation of the field type you ' re interested in
For more information)
Multivalued:true If this field may contain multiple values per document
Omitnorms: (Expert) set to true to omit the norms associated with this field (this disables length
Normalization and Index-time boosting for the field, and saves some memory). Only Full-text
fields or fields, need an index-time boost need norms. Norms is omitted for primitive
(non-analyzed) types by default.
Termvectors: [FALSE] set to true to store the term vector for a given field. When using Morelikethis,
Fields used for similarity should is stored for best performance.
Termpositions:store position information with the term vector. This would increase storage costs.
Termoffsets:store offset information with the term vector. This would increase storage costs.
Termpayloads:store payload information with the term vector. This would increase storage costs.
Required:the field is required. It'll throw a error if the value does not exist
Default:a value that should was used if no value is specified when adding a document.

2. Optimization
Performance Note:this schema includes many optional features and should not being used for benchmarking.
To improve performance one could
-Set stored= "false" for all fields possible (ESP large fields) if you have need to search on the
field but don ' t need to return the original value.
-Set indexed= "false" if you don't need to search on the field, and only return the field as a result
of searching on other indexed fields.
-Remove all unneeded copyfield statements
-For the best index size and searching performance, set "index" to false for all general text fields,
Use Copyfield to copy them to the catchall "text" field, and use that for searching.
-For maximum indexing performance, use the Concurrentupdatesolrserver Java client.
-Remember to run the JVM in server mode, and use a higher logging level that avoids logging every request

three. JAVA API simple to use
public class app{

private static solrclient client = NULL;

static{
Client = new Httpsolrclient ("Http://192.168.40.129:8983/solr/collection1");
}

public void Add () throws exception{
Solrinputdocument doc = new solrinputdocument ();
Doc.setfield ("id", "107");
Doc.setfield ("Email_box_title", "107hehehe");
Client.add (DOC);
Client.commit ();
}

public void Remove () throws Exception {
Client.deletebyid ("106");
Client.commit ();
}

public void query () throws Exception {
Queryresponse resp = client.query (New Solrquery ("id:10*"));
Solrdocumentlist doclist = Resp.getresults ();
for (Solrdocument doc:doclist) {
System.out.println (Doc.getfieldvalue ("id") + ":" +doc.getfieldvalue ("Email_box_title");
}
}

public static void Main (string[] args) throws Exception {
App app = new app ();
App.add ();
App.query ();
}
}

solr-5.3.1 Study (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.