1
votes

I am starting to learn Solr (using version 5.5.0). I am using managed-schema and data-congif.xml files to inex two sql server tables: Company & Contact.

I am able to execute from the UI, the data import, selecting one entity at a time.

This is the message I get for Company:

Indexing completed. Added/Updated: 8,293 documents. Deleted 0 documents. (Duration: 01s) Requests: 1 (1/s), Fetched: 8,293 (8,293/s), Skipped: 0, Processed: 8,293 (8,293/s) Started: less than a minute ago

This is the message I get for Contact:

Indexing completed. Added/Updated: 81 documents. Deleted 0 documents. Requests: 1, Fetched: 81, Skipped: 0, Processed: 81 Started: less than a minute ago

When I click the Query section, I want to perform a query to see all the Contact, and/ or Company records, not necessarily combined, but just be able to query them.

I am not sure how to do this, is it possible to get some help to understand how to specify against which entity I want to execute the query?

Here are the 2 files I modified:

data-cofig.xml:

<dataConfig>
  <dataSource type="JdbcDataSource" 
              driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" 
              url="jdbc:sqlserver://sql.server.com\test;databaseName=test"
              user="testusr" 
              password="testpwd"/>
  <document>
    <entity name="Company" pk="CompanyID" query="SELECT * FROM tblCompany">
       <field column="CompanyID" name="company_companyid"/>
       <field column="Name" name="company_name"/>
        <field column="Website" name="company_website"/>
        <field column="Description" name="company_description"/>
        <field column="NumberOfEmployees" name="company_numberofemployees"/>
        <field column="AnnualRevenue" name="company_annualrevenue"/>
        <field column="YearFounded" name="company_yearfounded"/>
    </entity>

    <entity name="Contact" pk="ContactID" query="SELECT * FROM tblContact">     
      <field column="ContactID" name="contact_contactid"/>
      <field column="FirstName" name="contact_firstname"/>
      <field column="MiddleInitial" name="contact_middleinitial"/>
      <field column="LastName" name="contact_lastname"/>
      <field column="Email" name="contact_email"/>
      <field column="Description" name="contact_description"/>
    </entity>
  </document>
</dataConfig>

managed-schema:

  <!-- Company Begin -->
  <field name="company_companyid" type="string" indexed="true"/>
  <field name="company_name" type="string" indexed="true"/>  
  <field name="company_website" type="string" indexed="true"/>  
  <field name="company_description" type="string" indexed="true"/>
  <field name="company_numberofemployees" type="string" indexed="true"/>
  <field name="company_annualrevenue" type="string" indexed="true"/>
  <field name="company_yearfounded" type="string" indexed="true"/>
  <!-- Company End -->

  <!-- Contact Begin -->
  <field name="contact_contactid" type="string" indexed="true" />
  <field name="contact_firstname" type="string" indexed="true"/>
  <field name="contact_middleinitial" type="string" indexed="true"/>
  <field name="contact_lastname" type="string" indexed="true"/>
  <field name="contact_email" type="string" indexed="true"/>
  <!-- Contact End -->

UPDATE

I tried using the fl field to select company_companyid, but I did not get any results.

I am including a screen shot:

enter image description here

1
Just to make sure I understand, you want to be able to execute a query and get, for example, only fields related to the Contact entity? - TMBT
I want to be able to execute a query and get fields for company, or contact, not combined, just as needed. Either a query against company fields, or a query for contact fields. I hope this makes sense. Thank you. - erasmo carlos

1 Answers

0
votes

To get fields as needed from a document, use fl. For example, if you were using SolrJ, you would have something like query.set("fl", "fieldA, fieldB").

In a URL, it looks like this: http://host:port/solr/coreName/select?q=*%3A*&fl=fieldA,fieldB&wt=json&indent=true