Posts

Showing posts from March, 2017

Apache Solr - Running Search Query

Image
By now, we have indexed sample data  of books.csv that comes with Solr. Lets see how to run Search Query in books data. Running Queries on Solr Open Solr Admin UI in a browser using http://localhost:8983 and choose the core1 under "Core Selector" dropdown list on left nav bar. You can see the number of total documents index by that core in right section of the page, as below: To run search query on core1 , choose the query link at left menu, you would a query builder UI, as below. Figure 2: Setting Search Query Admin UI, see Figure 2, provides user friendly way to build search query. Solr Admin passes all specified parameters to Solr API and shows the results return by the API on right section of the page. Solr Admin Query component is good tool to test search queries before we integrate them in our applications. If you leave all options to their default values and click "Execute Query" button, Solr would return the below JSON. You see, its same da

Apache Solr Index Sample Data

Start Apache Solr instance using " solr start " from bin directory of Apache Solr home directory. Or see first article how to setup Apache Solr and start it first time . Create New Core  Before we index sample data, we must create a core.  Core is like a table that contain many records and has a unique configuration. Each record in Solr is called a document . So we create core and add documents to it which are indexed by the Solr, so that we could search. One Solr instance may have more than one cores, each with different set of documents and unique configurations. So we need to create a core, before we add documents into it. Here is how we create a core: 1. In CLI, go to bin directory e.g. D:\solr-6.4.2/bin> and issue following command: solr create -c core1 -d basic_configs -c specifies the core name -d specifies the folder that contains core configuration data. Solr instance already have a folder named basic_configs which contains default configuration inf

Apache Solr Introduction and Server Setup

Image
Introduction to Apache Solr Apache Solr is a search server built as a web-application using Java language. Its not directly used by end-users to perform search operations on organizational data but by software developers (called Search Engineers) to integrate their softwares or applications with Apache Solr to use Solr search features. That means, Solr interface (way to interact with Solr) is not built for humans but for programs. Developers first submit their data to Solr using Solr RESTful API, the data is indexed by Solr. Once the data is indexed, developers send search queries with different filters (to refine search) to Solr server using Solr APIs. Solr returns the results in JSON or XML fromat that is parsed and displayed to end-users. Apache Solr Admin Interface Apache Solr provide Admin Interface but its target users are not end-users because it requires technical knowledge to use. Admin Interface is used by Search Engineers to test search queries, modify schemas and

Task 6: Arrays

Updated On: Oct. 31, 2020 6.1: Make an array of n elements and initialize it from user input. Get n from user. Print all the numbers, find and print the minimum number and its index in the array, find maximum number and its index in the array, find the average of all numbers. 6.2: Roll a 6 faces dice 1 million times, print how many times each face appear along with its percentage? Use arrays to store each face count e.g. face[3] shall store how many times 4 appeared during random rolls. See figure 7.7 of book for detail (Java How to Program, By Dietel. 10th Edition). 6.3: Make a program that shuffle cards. Print the deck before shuffling and after shuffling. See Figure 7.9, 7.10 and 7.11 from reference book. 6.4. Update  Task 5 such that PhoneNumber shall be an instance attribute of Student. To let user store multiple phone numbers, define phoneNumbers attribute of type PhoneNumber[]. Encapsulate phoneNumbers field. When creating a Student object, let user enter how many numbers a

Using Instance Variables, Methods and Constructors in Enum

Image

How Enum Work and Enum Constants Detail

Image
Enum contants detail is explained in this video. First I discuss basic concepts required to understand Enum constants e.g. public access modifier, what are static and final fields. When we can make private constructor and can we define field of same class type in which it is declared. After these basics, I explained enum constants are just public static final fields of same class/enum type. Whenever we refer to these constants, we refer to same distinct objects stored in main memory. When we assign these references to others, JVM make copy of their reference only, it do not create new objects. Constructor of enum is private, so we can't create new objects of enum type from other classes.

Using enum for list of constants in Java

Image

Using List of Constants Without Enum in Java

Image

Task 5: Composition

Image
Task Last Updated on: Oct. 21, 2020 A class may have references to objects of other classes as members, its called composition . For example Car is composed of Engine and Wheels objects. User class has name, Address and age attributes, etc. Composition is also referred as " has-a" relation because we can make statement like "Student has-a name", "Rectangle has-a length", "Car has-a Engine" etc. Below task is to make sure you well understand how to use other types as attributes or fields in our classes. How to initialize these attributes, how to change and read the values of them. Task 5.1 For each attributes described below, choose appropriate data type. All the attributes of each class should be private and exposed via get/set methods. Also define at least one constructor that allows to initialize 2-3 attributes of object. Define a class Course with courseCode and courseTitle instance variable. Define PhoneNumber class with countryCode, cityCode