zhengyu zhengyu - 7 months ago 39
SQL Question

Solr query doesn't show all the fields

I am learning solr (5.5.0) and running in a standalone mode.

Here is the solr-data-config.xml:

<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1/DBN" user="root" password="root"/>
<document>
<entity name="planexample" query="select * from plan where userid=60 limit 3">
<field column="planid" name="id" />
<field column="userid" name="userid" />
<field column="planname" name="planname" />
<field column="del" name="del" />
</entity>
</document>
</dataConfig>


And I add fields accordingly into managed-schema:

<field name="userid" type="int" indexed="true" stored="true" required="true" multiValued="true"/>
<field name="planname" type="string" indexed="true" stored="true" required="true" multiValued="true"/>
<field name="del" type="int" indexed="true" stored="true" required="true" multiValued="true"/>
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />


But when I do query on the webpage of solr, for example,
ip:8983/solr/corename/select?q=del%3A1&wt=json&indent=true
or
ip:8983/solr/corename/select?q=userid%3A60&wt=json&indent=true
, results only show the
id
except
userid,planname,del
, how to make those fields visible in results? And what does the
score
field mean in results?

One example of results:

{
"responseHeader": {
"status": 0,
"QTime": 1,
"params": {
"indent": "true",
"q": "del:1",
"_": "1461050814466",
"wt": "json"
}
},
"response": {
"numFound": 10,
"start": 0,
"maxScore": 0.90468985,
"docs": [
{
"id": "985963",
"score": 0.90468985
},
{
"id": "1033572",
"score": 0.90468985
},
{
"id": "1763216",
"score": 0.90468985
}
]
}
}

Answer

You need to provide a fl parameter, to get all stored fields, do &fl=*, or a comma seperated list of fields you want i.e. &fl=id,userid,planname,del for example.

Comments