I. Project structure
Second, pom. XML
Add springboot, Solr, and Freemarker dependencies to the pom.xml file
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency> <dependency> <groupId>cn. Hutool </groupId> <artifactId>hutool-all</artifactId> <version>5.2.0</version> </dependency> <! <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <! -- Solr dependencies introduced by the Spring Boot project --> <! Solr </groupId> <artifactId>solr-solrj</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-solr</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> The < version > 1.16.14 < / version > < scope > provided < / scope > < / dependency > < / dependencies >Copy the code
Three, make. FTL template
1. Create excel template and fill in some fake data to facilitate subsequent positioning
2. Save as XML format
3. Change the suffix to FTL
4. Handle FTL files
Remember to delete the ss:ExpandedRowCount=”5″, as you will always exceed the 5 limit when iterating through the table. Deleting means that the number of rows in the table is not limited
5. Put stat.ftl into resources/templates
4. Use SolR on Springboot for multi-field grouping statistics
HttpSolrClient DEFAULT_PATH is “/select” by default, and there is no place to change the path, so if solr service has custom /select, you can copy the source code. Then create a local HttpSolrClient with the same name, refer to my project structure **
What is the difference between Q and FQ parameters in SOLR?
If you use q=content:” China “, you will find all content that contains “China” and order by score, which will sort by content similarity.
If fq is used,q is set to *:. Solr will first order by score, and since the condition is :*, so all documents are the same correlation, so even if using FQ filter, return the first rank but not the highest correlation.
To sum up, if correlation (Score) is taken as the priority condition, then the condition must be placed in the Q parameter, while FQ is only the filtering of the condition without weight correlation as the priority.
5. Encapsulate the data, render it to FTL template, and export it to EXCEL
Yml configuration: Freemarker template load path. There are a lot of default configurations, but these two lines will do the job. For special configuration requirements, please visit the official website
Source code address :github.com/AsLightJava…
If you are not clear or have problems, please leave a message and contact me.