查询例子1:
GET请求:http://localhost:8983/solr/collection1/select?q=*:*&fl=name,id&wt=json&fl=*
分析:q=*:* 表示 属性:属性值中包含的词
fl=* 表示 查询的结果返回所有的属性值
返回的内容:
{
"responseHeader": {
"status": 0,
"QTime": 1,
"params": {
"fl": [
"name,id",
"*"
],
"q": "*:*",
"wt": "json"
}
},
"response": {
"numFound": 2,
"start": 0,
"docs": [
{
"id": "SOLR1000",
"name": "Solr, the Enterprise Search Server",
"manu": "Apache Software Foundation",
"cat": [
"software",
"search"
],
"features": [
"Advanced Full-Text Search Capabilities using Lucene",
"Optimized for High Volume Web Traffic",
"Standards Based Open Interfaces - XML and HTTP",
"Comprehensive HTML Administration Interfaces",
"Scalability - Efficient Replication to other Solr Search Servers",
"Flexible and Adaptable with XML configuration and Schema",
"Good unicode support: héllo (hello with an accent over the e)"
],
"price": 0,
"price_c": "0,USD",
"popularity": 10,
"inStock": true,
"incubationdate_dt": "2006-01-17T00:00:00Z",
"_version_": 1546511824707387400
},
{
"id": "3007WFP",
"name": "Dell Widescreen UltraSharp 3007WFP",
"manu": "Dell, Inc.",
"manu_id_s": "dell",
"cat": [
"electronics and computer1"
],
"features": [
"30\" TFT active matrix LCD, 2560 x 1600, .25mm dot pitch, 700:1 contrast"
],
"includes": "USB cable",
"weight": 401.6,
"price": 2199,
"price_c": "2199,USD",
"popularity": 6,
"inStock": true,
"store": "43.17614,-90.57341",
"_version_": 1546511824826925000
}
]
}
}
查询例子2:
GET请求:http://localhost:8983/solr/collection1/select?q=Search&fl=name,id
&wt=json&fl=*
分析:q=Search 表示 所有属性值中必包含的这个词,不一定所有属性都包含,也可以为*。
fl=* 表示 查询的结果返回所有的属性值
返回的内容:
{
"responseHeader": {
"status": 0,
"QTime": 36,
"params": {
"fl": [
"name,id",
"*"
],
"q": "Search",
"wt": "json"
}
},
"response": {
"numFound": 1,
"start": 0,
"docs": [
{
"id": "SOLR1000",
"name": "Solr, the Enterprise Search Server",
"manu": "Apache Software Foundation",
"cat": [
"software",
"search"
],
"features": [
"Advanced Full-Text Search Capabilities using Lucene",
"Optimized for High Volume Web Traffic",
"Standards Based Open Interfaces - XML and HTTP",
"Comprehensive HTML Administration Interfaces",
"Scalability - Efficient Replication to other Solr Search Servers",
"Flexible and Adaptable with XML configuration and Schema",
"Good unicode support: h¨|llo (hello with an accent over the e)"
],
"price": 0,
"price_c": "0,USD",
"popularity": 10,
"inStock": true,
"incubationdate_dt": "2006-01-17T00:00:00Z",
"_version_": 1546511824707387400
}
]
}
}
Hit highlighting returns relevant snippets of each returned document, and highlights terms from the query within those context snippets.
返回的形式:这会导致高亮的部分会显示在返回值上相关的高亮的词语上包含在<em></em>(for emphasis) tags
get请求URL: http://localhost:8983/solr/collection1/select?q=Search&fl=name,id&wt=json
&hl=true&hl.fl=features
返回值:
{
"responseHeader": {
"status": 0,
"QTime": 46,
"params": { //请求参数
"fl": "name,id", //请求返回的属性值
"q": "Search", //关键词搜索
"hl.fl": "features", //高亮所包含的关键词
"wt": "json", //返回的形式
"hl": "true" // 是否高亮
}
},
"response": {
"numFound": 1,
"start": 0,
"docs": [
{
"id": "SOLR1000",
"name": "Solr, the Enterprise Search Server"
}
]
},
"highlighting": {
"SOLR1000": {
"features": [
"Advanced Full-Text <em>Search</em> Capabilities using Lucene"
]
}
}
}