Saturday, 14 October 2017

Endeca Interview Questions part 1

Hi All,
      Many of us before going to attend any interviews , they want to know how much they have prepared for the Interview  so they will be testing their knowledge with the questions , I am sure this post going to be useful in that aspects for the ATG-Endeca Integration Developers . I will be covering from the basic to the compex Questions here .

1)What is Endeca ?
2)What is the Expansion of ITL?
3)Explain Forge Process in Endeca ?
4)What is MDEX?
5)What are the Components of MDEX?
6)What is Tools and Frameworks and Explain their Functionality?
7)What is Platform Services and Explain their Functionality?
8)What is CAS and Explain their Fuctionality?
9)Explain the Order of Installation if Endeca Components?
10)Explain Digix?
11)Explain Dgraph? 
12)Explain the Full Form of EAC and their Architecture?
13)Explain the Steps to be Followed while creating the Endeca Application?
14)What is Deployment Template and how it ca be used ?
15)What is the Full Form of XM?
16)Explain the uses of WorkBench?
17)Explain the uses of XM?
18)Explain about the ECR Repositroy and Mention about their uses?
19)What are record Stores in endeca?
20)What is last-mile crawl?
21)Explain about Indexing Process from Baseline Script perspective .?
22) How to make Dimension id same across all the environments?
23)What is Crawling and how it can be achieved .?
24)What are the cartridges ?
25)What are the templates ?
26)How to create cartridges and promoting it ?
27)What is Index Config ?
28)How ATG Interacts with Endeca ?
29)Component responsible for triggering Indexing ?
30)How to Schedule Indexing ATG?
31)How to set RecordFilterable as property?
32)Wat is Rollup key and how to define it ?.
33)What is property and Dimensions ?
34)Script Called from Endeca During BaselineIndex
35)What is Partial Indexing?
36)What is Baseline Indexing?
37) What is the Script Called During Baseline Indexing ?
38) What is the Script Called During the Partial Indexing?
39)Definition file for Defining te Indexables Components in ATG
40)What is Endeca Pipeline
41)What are Search Interfaces in endeca ?
42)What are Record Search in endeca ?
43)What are Dimension Search in endeca ?
44)What is Endeca_jspref?
45)Attribute used to define for the level  of Indexing in definition file?
46)How many records are computed by guided search if the same record is linked in the two or more category.?
47)Which Component outputs dimension Value records for all of the repository items types.?
48)What is Multi Select in Endeca Dimensions ?
49) How do you define a property as multiselect or and Explain it ?
50)How do you define a property as multiselect and Explain it ?
51)How do you enable the assembler for your application.?
52)what is the entry point of the request for assembler based applications?
53)What is Assembler Pipeline servlet?
54)What are the twotypes of input paramteres in InvokeAssembler?
55)Types if Content invoke in AssemblerPiplelineservlet?
56)Which Component is responsible for connection to MDEX from Assembler.?
 57)How is  the cartride configurations will be avalible as part of your handler?
58)What is Catridge Config?
58)What are Cartridge Handlers ?
60)How Cartridges can be linked to Handler Mapping done through ?
61)What are default Methods in Cartridge handlers ?
62)How the Endeca Content is Accessible in ATG?



Happy Learning and new Beginning !!!!


........................To Be Continued 


Saturday, 23 September 2017

Working with Statelessness in JAX-RS

Before Pitching in to the "How the Stateless works with the JAX-RS" , I want to discuss here about the basics of the stateless and how it can be created and what are the configurations required .


So What is Statelessness ? It is said that , while processing the request , the server does not maintain any state or the Information that is required , If it is not maintaining it, how can be proceed yes the client sends the information that is required to process the request this behavior is called as the statelessness .

JAX-RS implementation With ATG Commerce has support for this statelessness and we can see how we are going to enable it .

We all know that, we are generating the Ear for the ATG Application from the RunAssembler , and we are passing all the arguments while executing the RunAssembler.So to enable the Statelessness we have to pass the stateless argument for the RunAssembler . Once it if passed then the Required Modules are built along with it . I am just pasting the Snippet you can use the same for the ant build .For other Maven you see their manuals before using it .

               <arg line="stateless"/>

Now you have enabled the stateless mode .So the Beauty of the Statelessnessis that, all the session scope components in ATG will be converted in to the Request Scope Components .

So now its our time to See more about the functional aspects .

So what is x-ocstatedata ? I was mentioning about the required data must be passed as part of the Request from the client , this will be carried by this x-ocstatedata .

Did I need to create this x-ocstatedata every time? . No you need to create it OOTB takes care of creating it , but it is your responsiblity to put the data in the way OOTB expects then the x-ocstatedata is created automatically, So How to put it ? let see in the below .

Create a class extends GenericService implements MapLoadableService . When you create like this
there should be two methods that needs to implemented .

1))@Override
public void loadService(Map<String, Object> paramMap) {
}

//This method is the place where we have to read the previous state from the x-ocstatedata and used for the current request .

2)@Override
public Map<String,Object>getProperties() {
}
// This is the method where we need to write a logic so that it returns the request data that has to be put as part of the X-ocstatedata . Which is of type Map<String,Object>. This method will be called after each endpoint finishes . 


For More Information on the Implementation details you can refer the ProfileLoadableService OOTB class  . Where they have used the Profile component from the x-ocstatedata .

You can inject the created component in the RequestStateManager as below 

loadableServicePaths=\
                                       /atg/userprofiling/ProfileLoadableService


Once it is declared in the component path it will be called before it hits any service and end of the service calls .

By Following the above way you can Handle the stateless data in the JAX-RS.


Exception Handling in JAX-RS

In JAX-RS Implementation of REST, Each and every Exception should be handled as the Rest Exception as the OOTB Handles it , We can utilize the OOTB features to the Fullest by consuming this Classes and throwing the way it does , we can Briefly see how to handle it .

ATG 11.3 JAX-RS Implementation has inbuilt class RestException for handling this .  RestException  is the class that has different constructors for Providing the required inputs to be passed while Throwing it .

RestException error = RestUtils.getRestUtils().createException(400, "500", "Internal Server Error", null, null);

throw error;

Same like this above will have many constructors 

From the above example A RestException class can be instantiated
through utility methods in RestUtils , hence we are injecting in this way and supplying the parameters.

If you add error conditions to your endpoint, you should build a RestException, setting HTTP response codes,error messages, debug information and, optionally, error codes that are returned from your endpoint method.

400 is the status codes .

500 is the "internalserver" ie error codes

"Internal Server Error" is the message 

The RestExceptionMapper instance of the Jersey ExceptionMapper builds a response from the RestException that is returned to the client.If you want to handle any custom unhandled exceptions you can write the code here for handling it .


Additinally Every REST method should be constructed with an error message,which should be stored as resource strings in a property file residing in your custom module. Once you have constructed an error message, you can create string constants that refer to the error string keys within your endpoint class.


I am gives some of the status codes which you can use it while developing it .


ACCEPTED 202 Accepted
BAD_REQUEST 400 Bad Request
CONFLICT 409 Conflict
CREATED 201 Created
FORBIDDEN 403 Forbidden
GONE 410 Gone
INTERNAL_SERVER_ERROR 500 Internal Server Error
MOVED_PERMANENTLY 301 Moved Permanently
NO_CONTENT 204 No Content
NOT_ACCEPTABLE 406 Not Acceptable
NOT_FOUND 404 Not Found
NOT_MODIFIED 304 Not Modified
OK 200 OK
PRECONDITION_FAILED 412 Precondition Failed
SEE_OTHER 303 See Other
SERVICE_UNAVAILABLE 503 Service Unavailable
TEMPORARY_REDIRECT 307 Temporary Redirect
UNAUTHORIZED 401 Unauthorized
UNSUPPORTED_MEDIA_TYPE 415 Unsupported Media Type

It is our duty to set the correct status codes and error codes while throwing it .

Happy Handling !!!!


Friday, 22 September 2017

JAX-RS Basics - Getting Started : Sample Program

Hi All,
     
        Hope all are doing well, Today we are going to see some Interesting Basics of the JAX-RS .

JAX-RS Implementation was Introduced in the Oracle Commerce Platform 11.3 , with this Standard Oracle was able to competate the Industrial Standards,   in the REST Services . So Lets Deep in to .

1) The First Step to start with the JAX-RS Application is add the Following entry in the web.xml

<servlet>
    <servlet-name>Jersey</servlet-name>
    <servlet-class>atg.service.jaxrs.JerseyServletWrapper</servlet-class>
    <init-param>
        <param-name>atg.service.jaxrs.JerseyServletWrapper.servletClasses
</param-name>
        <param-value>org.glassfish.jersey.servlet.ServletContainer,
atg.service.swagger.SwaggerBootstrap</param-value>
    </init-param>
    <!-- Params for JerseyServletWrapper servlet -->
    <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>atg.service.jaxrs.JAXRSApplication</param-value>
    </init-param>
    <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>atg.service.swagger.SwaggerApiListingResource,
io.swagger.jaxrs.listing.SwaggerSerializers</param-value>
    </init-param>
    <init-param>
        <!-- Params for JAXRSApplication -->
        <param-name>atg.service.jaxrs.JAXRSApplication.resourceRegistryPath
</param-name>
        <param-value>/atg/dynamo/service/jaxrs/RestResourceRegistry</param-value>
    </init-param>
    <init-param>
        <param-name>atg.service.jaxrs.JAXRSApplication.validatorRegistryPath
</param-name>
        <param-value>/atg/dynamo/service/validator/ValidatorRegistry</param-value>
    </init-param>
    <init-param>
        <!-- Params for SwaggerBootstrap servlet -->
        <param-name>atg.service.swagger.SwaggerBootstrap.bootstrapService
</param-name>
        <param-value>/atg/dynamo/service/swagger/SwaggerBootstrapService
</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
    <async-supported>true</async-supported>
</servlet>
<servlet-mapping>
    <servlet-name>Jersey</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

Once if you add the Following entry then the JAX-RS is enabled in the application, we can go ahead and creating our Resource classes . 

From the above XML there is a path for defining the RestResourceRegistry,Validatory Registry and SwaggerBootStratService , if you are defining your Custom you can update to point yours. For SwaggerBootStratService and ValidatoryRegistry give the OOTB Component path this is required till you start diving in to more . 

2)You can add the mentioned classes  are avaliable in the DAS, Rest Modules you can add the Reference in the Build Path once it is done ,these will be available for your project  .Make Sure you Resolve the Dependency issue  of the Jars. 

3)Start Creating the Component in the path /atg/dynamo/service/jaxrs/RestResourceRegistry
this is the Component where we have register the Components created on behalf of the JAX-RS implementaiton.

nucleusRestResources : this property hold those components .

Those components can be created by the Following way 

4)Create a class extends GenericService

@RestResource(id=OrderRestConstants.CURRENT_ORDER_ID)
@Path("/cart")
@Api(value="/cart")
public class CurrentOrderRestResource extends GenericService {
}

Here@RestResource – must be present for all resource classes, as it specifies the ID of the
resource. The ID is a string that uniquely identifies the resource and does not change when the context and/or version change.Try to give the package name as well.

@Path . The annotation contains the URI path for the resource. For example, @path ("/cart"). Note: If you are creating a sub-resource,ensure that there is no @Path annotation.

Create like above example . Next Will Start Writing the methods 

@GET
@Endpoint(id="/cart#GET" filterId="cart-Default")
@ApiOperation(value="Gets the current order.")
public Object getOrder(JSONObject pJson) throws RestException, CommerceException {
}

@GET, @POST, @PUT, @PATCH, and, @DELETE – These annotations are used as necessary when working with the endpoint.

@Endpoint – This annotation identifies the endpoint with a unique string ID. The ID does not change if the context or version changes. If the endpoint is for a singular resource, the isSingular attribute must be true.

5)A resource’s schema is controlled using the ValidatorManager component and payloadSchema.xml files.These XML files configure multiple validators that contain the definitions for expected input fields, as well as required output fields. Endpoints can specify which validator definition to use for input, using the validatorId attribute, and for output, using the filterId attribute.Will Discuss Brief more about this in the upcoming Sessions .

6)Write the Logic here and return type should be the Object , this is required because we are returning the RepresentationModel . 


The RepresentationModel is a holder class that allows you to build a representation of a resource for aresponse. It contains properties that specify the resource state, embedded resources, collection members, links,headers, and other properties. If an endpoint needs to respond with a representation of the resource, create an instance of this class.

7)Register the Class which we have created in to the Component and declare that component to the RestResourceRegistry component  nucleusRestResources property. 

8)How End Point Works .

Resources are registered with a REST resource registry that has a context root defined in the web.xml file. This context root takes the following format:


 <context-param>
    <param-name>context-root</param-name>
    <param-value>/public/v1</param-value>
  </context-param>


For example, a URI may be /public/v1. The full URI would be http://localhost:8080/public/v1.

Then the corresponding end point we have to invoke . In our Scenario of above example it is like 
http://localhost:8080/public/v1/cart/ this will change as per our Requirement. 


Try to access your First Ever JAX-RS application .

We will  start looking in to the advance concepts in the upcoming Tutorials . You can also take a look at the OOTB Classes on the JAX-RS implementation for more technical Stuffs.

Happy Learning !!!!!

Tuesday, 5 September 2017

Logging in Endeca Assembler

Hi All,
        Most of Us will be very keen about Debugging the Code via Logging , this is Because this Prints the line it need .

So here is a solution for you and how to implement in Endeca. By Default Endeca OOTB code has very limited set of Logging . If you want to enable logging , most of the Class does not extend the Generic Service so no logging !! Dont Worry, Blindly Follow the Below Steps , you can enable logging for your Application .

I would Recommend of using the Same logging all the Places , because when you enable in one Component all the Corresponding components will print it from Starting of the Request and When Request is Becoming Death.

you can use the below snippet wherever it is required .

VariableArgumentApplicationLogging mLogger = AssemblerTools.getApplicationLogging();

usauge will be as follows mLogger.isLoggingDebug()

apart from this you will get all the loggings .


Happy Logging !!!!

Tuesday, 8 August 2017

Machine Learning

There was hot talks around my team, when I received a mail stating that the Machine Learing Experience has been Implemented in the Elastic Search.

So What Actually is the Machine Learning Definition (Copied)


"Machine learning is a method of data analysis that automates analytical model building. It is a branch of artificial intelligence based on the idea that machines should be able to learn and adapt through experience."
So What is Machine Learning in the Plain Terms, System Learns by itself by the Previous Behavior or the Use Cases . What System is Learning by Itself !!! what will be the Future of the Developers who codes pages by Pages , don't worry we have not knocked out , still we have to write the recepies for it (Can See Brief When we are Exploring More).
Now as a Start , I will Share Some Information about the Elastic Search "X Pack" Tool they termed "Anomaly" which can be used to Identify the Troubles . It has the Following Features 
IT Operations: Spot an unusual drop in application requests, then drill in on the troublesome server contributing to the problem.
Security Analytics: Identify unusual network activity or user behavior to pinpoint attackers before they do damage.
Business Analytics: Get notified if there is an unusual increase in abandoned shopping carts in your ecommerce site. 
They also given the Recepies for Implementing it . I am Sure Gonna Try How Does it Works in the Real time . Oracle also identifying this type of Behavior not sure how they are handling want to explore . 

Monday, 7 August 2017

Customizing “q” Parameter in SOLR

Hi All,
         Today we are going to see how we are going to customize the Search parameter in solr. Almost all of our Projects will be having the Requirement of Customizing this parameter. Please follow the Below Instructions so you can change it easily.

package com.mycommercesearch.solr;
              
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.handler.component.SearchHandler;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;

public class SearchEndecaHanlder extends SearchHandler {
      
       public static String SEARCH="search";
      
       public static String QUERY_PARAM="q";

       public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)   throws Exception{
              String queryParam=req.getParams().get(SEARCH);
              SolrParams paramSolrParams = req.getParams();
              NamedList<Object> nmList = new NamedList<Object>();
              nmList=paramSolrParams.toNamedList();
              nmList.remove(SEARCH);
              nmList.add(QUERY_PARAM, queryParam);
              paramSolrParams=SolrParams.toSolrParams(nmList);
              req.setParams(paramSolrParams);
              super.handleRequestBody(req, rsp);
       }
}

In this Scenario I have used "search" instead of  "q" and it worked out. Create a Jar File from the above class and paste it in <SOLR_ISTALED_DIR>solr-6.6.0\server\solr-webapp\webapp\WEB-INF\lib\

Registering the Custom Handler in Solr

Navigate to Solrconfig.xml and add the below entry.

<requestHandler name="/mysearch" class="com.mycommercesearch.solr.SearchEndecaHanlder">
    <lst name="defaults">
      <str name="echoParams">explicit</str>
      <int name="rows">10</int>
      <!-- <str name="df">text</str> -->
    </lst>
  </requestHandler>

Once if you restart and access with the Below Url and get the Results .



Happy Searching !!!!

Exception Handling in Endeca

Hi All,
  I am Going to Share Some Basics note about Exception Handling in Endeca . We will be having Many Scenarios that has to be handled, so that the Users will not lead to seeing the Error or the Exceptions. I am sharing my Experience it varies from the Implementation Perspective from developers to developers .

When we are implementing the Assembler Approach there are only two types of Exceptions will be land in to and we have to handle everything within it.

Exception
Description
AssemblerException
This Exception states that the exception occurred during the process or creating the Assembler Request. Eg ene Query,Host Exception
CartridgeHandlerException
This Exception Occurs while calling the single Cartridge handler, usually exceptions like NPE,Range Exceptions .

Well, we have Seen These Two Exceptions and next step is to how to bring these Exceptions in to our applications. When the endeca contentItems are rendered from the JSP then it is with the Developer, who renders it and no need to worry about this status. Where else we are going with the Rest or the JAX-RS Approach which requires these Scenarios to be handled before Sending the Status to the Service.

When you see the Architecture, there is no way we can handled the Exception Thrown. So what we have to do? Customize the Invoke Assembler or Assembler Tools only for the Exceptions? Not required.

So here is what you have to do, When the Assembler Exception Happens or the Cartridge Handler Exceptions Happens you are able to see the @error Param on the Content Item, when you go in to this param , you could able to see the type of exception. You can write a wrapper on top of the Calling type method for example in the Actor Chains, if it is going to be the Rest MVC architecture and Nucleus Resource Class in case of the JAX-RS Implementation, take the ContentItem that InvokeAssmbler Returns send it the Method and Parse it, weather it is network, Invalid key, NPE, Range, MDEX Down, Class Cast Exception and handle it appropriately based on the Type of Exception Status and Error Codes.. If the Content Item is null then blindly throw it as 500 Status .

I have handled in the above way Instead of throwing the Generic Exceptions, and it is working as Excepted. Hope you have understood the Easiest Way of handling the types of Exceptions in Endeca.

If you have any other Reference of handling it can Suggest Below.

Happy Learning !!!!!


Sunday, 6 August 2017

Tuning Weblogic Server - ATG Servers

Hi All,

     I Was Facing the Slowness in Starting my weblogic server, I cannot point out the Exact Issue then googled it found the below solutions .

 Adding -Djava.security.egd=file:///dev/urandom or -Djava.security.egd=file:/dev/./urandom to JAVA_OPTIONS has helped me to solve the issue.

Hope your weblogic is Starting Fastly.


Happy Learning !!!!!

Clearing Cache In Linux

Hi All,
         Today, I was Facing error with Respect to the Memory , Though I have Enough Memory in my Machine, it's not Clearing out . 

How I identified this 

1) Executed the Command free -m 

this will give the Free Memory Report in the Linux Box.

2) I am Running only one Instance but taking lot of memory ,it  has not cleared the Cache Memory this can be cleared out by the Below Command .

 #!/bin/sh
sync; echo 3 > /proc/sys/vm/drop_caches


Make Sure you are running as the Root Before Executing this.

Happy Learning !!!!

Implementing Partial Indexing in Endeca

Hi all,
    After Spending more time with the Partial Indexing, I am Writing this posts, so it could be useful for the other people trying to implement the Partial Indexing for their Projects.

Usually all the Projects, would have Configured the Baseline Indexing in the Scheduled Manner, If We have got the Requirement of Indexing the Inventory From Endeca , Will think of Having the Partial Indexing Configured for the Scheduled Manner, the Constraint is that it cannot pick up the Changes, Since the Inventory Comes or updates as part of the Feed Process.

Before pitching in to the Discussion of that, let’s see what are all can be achieved with the Partial Indexing.

When the Deployment is made from BCC by Creating a new Proj will update/add the Properties , if the Properties Belong to the Same Repository.ie Adding the Promotion will not reflect after the Deployment and the  Partial Indexing , the Reason is that the Promotion belongs to the Different Repository not the Product Catalog.

So , How Does the Flow Goes or what is Behind the Scenes of the Partial Indexing ? .
Before Knowing the Flow, we all should aware of the Basics of Partial Indexing.


Basics of Partial Indexing

There is a Repository called the Incremental Item Queue that is Responsible for Triggering the Partial Indexing. We have a Property called the Monitored OutputConfigs that should have our Config paths eg: ProductCatalogOutputConfig , Article OutputConfig.

There Will be Generation Id Associated With the Each OutputConfig Paths. So During Deployment the Sku or the Product, or Article Will be Added to this Incremental Item Queue Repository along with the Generation Id and the Item Descriptor . During the Partial Indexing this table will be Flushed out by submitting those to the Indexing . If the Products are not loading as part of the Partial Indexing after knowing that Items are avalaible in Incremental Item Queue Repository, then the Problem with miss match of the GenerationId.

You are also should be aware if the Tables from the DB Where these Operations take place.

srch_update_queue: this Table Where will be having the
config_repo_id will be the Config id of the output config path .
item_desc_name will be the Item Descriptor name .
repository_id is the Id of the updated product / Sku .
generation is the value of the Current id .
change_type is the value of the Change Type .
please find the Below Example .

values ('14500010','product','product101','2279','0');

srch_config this table is the Place where will be getting the Config Repoid and Generation for the Particular Config Path.

So now you are aware of the Flow of Partial Indexing Flow. If your Requirement to Indexing comes as part of the Feed then you have to identify the Changed Items and Write explicitly in to the Incremental Item Queue and Scheduled the Indexing of the Partial then it will take.

If your Property Belongs to the Different ItemDescriptior or Repository , make sure that you are making the Linking to any of the property in the Product Catalog  after linking only it will be taken as part of the Indexing otherwise will not be taken.
Only those Properties that will not be added as part of the BCC Deployment , We have to Write Explicitly in to the Incremental Item Queue. Others not Required .

So Keep this Information or the Constraint in mind Before Start Implementing to your Application .


Happy Learning.!!!!! 

Monday, 31 July 2017

Avoiding PMD Checkstyles

Hi Users,
       Most of us Will Face the Burden of Fixing the PMD Checkstyles for assuring the Quality to Client With Respect to Code. This Can be a time Bound Activity and Requires some prior Planning to avoid it. I am Sharing my Views on it Which gave me the Consisting Improvement in Results .

1) Always Good Habit of Defining the Constants in the Seperate files rather than Hard Coding it.

2)Always follow the Way of Defining the Variable .

3)Remove the Unused Code or the Dead Code.

4)Don't make the Logic Complex by Writing a Complex Loops.

5)Don't Write Too Long Method/Classes, Break them then and there as part of the Code Commit.

6)For any Repository Calls and other Calls use the Configurable Value , and Avoid it defining in the handler Levels .

7)Make Sure you Write the Tools Class whenever it is required , instead of creating in the Same place.

8)Make Sure that your Code SatisFies You, before you commit.



Happy Learning !!!!!

Defining multiple entity In Solr

Most of us when implementing the Search for the Site , the data we are going to process is not from the Same Table and same fields , for information on how to Index the Data From Database can be seen in my previous blog here. This deals only with data from multiple datasources or the data from different tables here.

Navigate to db-data-config .xml and edit it. I am going to setup the Customer Data for Search here.

<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource name="ds1" type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/classicmodels" user="root" password="root"/>
<dataSource name="ds2" type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/customerdata" user="root" password="root"/>

Here is the place where, I can define the different datasources . Here I have configured two types of datasources, one is called ds1 and another called as ds2. You can have different Set like hsql and XML also defined for processing.

<document>
   <entity name="products" dataSource="ds1" pk="id" query="select * from products" deltaImportQuery="select * from products"
   deltaQuery="select * from products where last_modified > '${dataimporter.last_index_time}'">
     <field column="productCode" name="id"/>
     <field column="productName" name="name"/>
     <field column="productDescription" name="description"/>
                 <field column="productLine" name="category"/>
    </entity>    
    
In the products entity, unique key is the id and we can mention the data source also here.         

   <entity name="customers" dataSource="ds2"  pk="customerNumber" query="select * from customers" deltaImportQuery="select * from customers"
   deltaQuery="select * from customers where last_modified > '${dataimporter.last_index_time}'">
     <field column="customerNumber" name="id"/>
     <field column="customerName" name="customerName"/>
     <field column="contactLastName" name="contactLastName"/>
                 <field column="contactFirstName" name="contactFirstName"/>      
                 <field column="phone" name="phone"/>
                 <field column="addressLine1" name="addressLine1"/>
                 <field column="addressLine2" name="addressLine2"/>
                 <field column="city" name="city"/>
                 <field column="state" name="state"/>
                 <field column="postalCode" name="postalCode"/>
                 <field column="country" name="country"/>
     <field column="salesRepEmployeeNumber" name="salesRepEmployeeNumber"/>
                 <field column="creditLimit" name="creditLimit"/>
  </entity>
</document>
</dataConfig>


If you are introducing the new entity it is must to have field called the id , which is used for the uniqueness of the records.

Querying for products


Querying for customers


df is the data fields that holds this indexed data. Refrence is the datafield for products and customer is the datafield for customers.


Errors:

2017-04-22 10:24:17.256 WARN  (Thread-14) [   x:refrence] o.a.s.h.d.SolrWriter Error creating document : SolrInputDocument(fields: [category=Ships, id=S72_3212, name=Pont Yacht, description=Measures 38 inches Long x 33 3/4 inches High. Includes a stand.
Many extras including rigging, long boats, pilot house, anchors, etc. Comes with 2 masts, all square-rigged, _version_=1565373662235721728])
org.apache.solr.common.SolrException: [doc=S72_3212] missing required field: city


When you face the error you have to remove the field required=”true ” or make it “false” in managed-schema.xml as like below
                <field name="city" type="string" indexed="true" stored="true" required="false" multiValued="false" />

<field name="city" type="string" indexed="true" stored="true" multiValued="false" />


If you face below error

Solr Error Document is missing mandatory uniqueKey field id


It means your document does not have the property id which is defined like below in  <uniqueKey>id</uniqueKey> in managed-schema.xml


Happy learning !!!!

Faceting in Solr

Faceting can be defined as grouping up the grouping up the fields of search results, so that user can narrow down their search. Solr comes with simple implementation of it.




Parameter
Example
Explanation
facet
If this is set to true then facets are enable for the current search.
facet.field
Facets will be returned for these fields defined.
facet.prefix
This will return only the fields matching the prefix in the facets.
facet.contains
This will return the facets containing the term matching
facet.sort
This will sort the results based on the field given.
facet.limit
This will limit the facets to be returned.
facet.offset
This will display the facets from the given offset
facet.mincount
This will return the facets , having only the matching count.
facet.missing
This will return the facets that is matching query but not the facet matching
facet.method
Algorithm to be used .
facet.range
This has to be returned for range faceting