Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
9bff3dfc
Commit
9bff3dfc
authored
Jul 26, 2021
by
李传峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理solr升级
parent
7589af66
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
26 deletions
+48
-26
pom.xml
pcloud-solr/pom.xml
+6
-8
SolrUtils.java
pcloud-solr/src/main/java/com/pcloud/solr/SolrUtils.java
+42
-18
No files found.
pcloud-solr/pom.xml
View file @
9bff3dfc
...
@@ -14,10 +14,9 @@
...
@@ -14,10 +14,9 @@
<version>
${reversion}
</version>
<version>
${reversion}
</version>
<name>
pcloud-solr
</name>
<name>
pcloud-solr
</name>
<url>
http://maven.apache.org
</url>
<properties>
<properties>
<spring.data.solr.version>
2.1.7.RELEASE
</spring.data.solr.version>
</properties>
</properties>
<dependencies>
<dependencies>
...
@@ -25,7 +24,6 @@
...
@@ -25,7 +24,6 @@
<dependency>
<dependency>
<groupId>
org.springframework.data
</groupId>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-solr
</artifactId>
<artifactId>
spring-data-solr
</artifactId>
<version>
${spring.data.solr.version}
</version>
</dependency>
</dependency>
<!-- Spring Cloud Begin -->
<!-- Spring Cloud Begin -->
...
@@ -33,11 +31,6 @@
...
@@ -33,11 +31,6 @@
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-config
</artifactId>
</dependency>
<!-- Spring Cloud End -->
<!-- Common Dependency Begin -->
<!-- Common Dependency Begin -->
<dependency>
<dependency>
...
@@ -58,6 +51,11 @@
...
@@ -58,6 +51,11 @@
</dependency>
</dependency>
<!-- Common Dependency End -->
<!-- Common Dependency End -->
<dependency>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-spring-context
</artifactId>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
pcloud-solr/src/main/java/com/pcloud/solr/SolrUtils.java
View file @
9bff3dfc
package
com
.
pcloud
.
solr
;
package
com
.
pcloud
.
solr
;
import
java.text.ParseException
;
import
com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource
;
import
java.text.SimpleDateFormat
;
import
com.google.common.collect.Lists
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.
solr.client.solrj.SolrClient
;
import
org.apache.
commons.lang3.StringUtils
;
import
org.apache.solr.client.solrj.SolrQuery
;
import
org.apache.solr.client.solrj.SolrQuery
;
import
org.apache.solr.client.solrj.SolrServerException
;
import
org.apache.solr.client.solrj.impl.CloudSolrClient
;
import
org.apache.solr.client.solrj.impl.CloudSolrClient
;
import
org.apache.solr.client.solrj.response.QueryResponse
;
import
org.apache.solr.client.solrj.response.QueryResponse
;
import
org.apache.solr.common.SolrDocument
;
import
org.apache.solr.common.SolrDocument
;
import
org.apache.solr.common.SolrDocumentList
;
import
org.apache.solr.common.SolrDocumentList
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
/**
* Description solr全文检索工具类
* Description solr全文检索工具类
* @author PENG
* @author PENG
* @date 2018/4/23
* @date 2018/4/23
*/
*/
@Component
(
"solrUtils"
)
@Component
(
"solrUtils"
)
@
PropertySource
(
value
=
"classpath:public_system
.properties"
)
@
NacosPropertySource
(
dataId
=
"solr7
.properties"
)
public
class
SolrUtils
{
public
class
SolrUtils
{
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
SolrUtils
.
class
);
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
SolrUtils
.
class
);
...
@@ -38,6 +36,7 @@ public class SolrUtils {
...
@@ -38,6 +36,7 @@ public class SolrUtils {
private
static
final
SimpleDateFormat
UTC_FULL_DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
);
private
static
final
SimpleDateFormat
UTC_FULL_DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
);
private
static
String
defaultCollection
;
private
static
String
defaultCollection
;
private
static
String
hosts
;
protected
static
CloudSolrClient
solrClient
;
protected
static
CloudSolrClient
solrClient
;
...
@@ -545,11 +544,36 @@ public class SolrUtils {
...
@@ -545,11 +544,36 @@ public class SolrUtils {
@Value
(
"${solr.default.collection}"
)
@Value
(
"${solr.default.collection}"
)
public
void
setDefaultCollection
(
String
defaultCollection
)
{
public
void
setDefaultCollection
(
String
defaultCollection
)
{
SolrUtils
.
defaultCollection
=
defaultCollection
;
SolrUtils
.
defaultCollection
=
defaultCollection
;
initSolrClient
(
SolrUtils
.
hosts
,
SolrUtils
.
defaultCollection
);
}
}
@Autowired
@Value
(
"${solr.cloud.host}"
)
public
void
setSolrClient
(
SolrClient
solrClient
)
{
public
void
setSolrCloudHost
(
String
hosts
)
{
SolrUtils
.
solrClient
=
(
CloudSolrClient
)
solrClient
;
SolrUtils
.
hosts
=
hosts
;
SolrUtils
.
solrClient
.
setDefaultCollection
(
defaultCollection
);
initSolrClient
(
SolrUtils
.
hosts
,
SolrUtils
.
defaultCollection
);
}
private
void
initSolrClient
(
String
hosts
,
String
defaultCollection
)
{
if
(
StringUtils
.
isBlank
(
hosts
)
||
StringUtils
.
isBlank
(
defaultCollection
))
{
return
;
}
if
(
SolrUtils
.
solrClient
!=
null
)
{
return
;
}
try
{
List
<
String
>
hs
=
Lists
.
newArrayList
(
StringUtils
.
split
(
hosts
,
','
));
CloudSolrClient
client
=
new
CloudSolrClient
.
Builder
(
hs
).
build
();
client
.
setDefaultCollection
(
defaultCollection
);
LOGGER
.
warn
(
"SolrClient==>hosts:{}\tdefaultCollection={}\t{}"
,
hosts
,
defaultCollection
,
client
);
LOGGER
.
warn
(
"SolrClient Ping==>{}"
,
client
.
ping
(
defaultCollection
));
SolrUtils
.
solrClient
=
client
;
SolrUtils
.
defaultCollection
=
defaultCollection
;
}
catch
(
SolrServerException
|
IOException
e
)
{
LOGGER
.
error
(
"SolrClient initialized failed,{}"
,
e
.
getMessage
(),
e
);
throw
new
RuntimeException
(
"SolrClient initialized failed"
);
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment