Skip to content
Snippets Groups Projects
Commit 93e60671 authored by William Bell's avatar William Bell
Browse files

Renaming files

parent ec0be865
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
curl -X DELETE "http://localhost:9200/authors?pretty"
#!/bin/bash
curl -X DELETE "http://localhost:9200/solarsystem?pretty"
#!/bin/bash
curl -X DELETE "http://localhost:9200/publications?pretty"
File mode changed from 100644 to 100755
No preview for this file type
......@@ -65,7 +65,7 @@ The contents of the \texttt{search-authors.sh} script are given in Listing~\ref{
\lstinputlisting[caption={The file search-authors.sh.},label=listing:search-authors.sh,language=bash]{../search-authors.sh}
\item Delete the library index by running the script \texttt{delete-index-library.sh}, in a similar manner as Listing~\ref{listing:start-elasticsearch-run}.
\item Delete the library index by running the script \texttt{delete-index-authors.sh}, in a similar manner as Listing~\ref{listing:start-elasticsearch-run}.
\item Add publications to a new library index by running the script \texttt{add-publications.sh}, in a similar manner as Listing~\ref{listing:start-elasticsearch-run}.
......@@ -87,27 +87,27 @@ The contents of the \texttt{search-publications-2.sh} script are given in Listin
\lstinputlisting[caption={The file search-publications-2.sh.},label=listing:search-publications-2.sh,language=bash]{../search-publications-2.sh}
\item Run the Python script \texttt{search\_publications.py}, in a similar manner as Listing~\ref{listing:start-elasticsearch-run}.
\item Run the Python script \texttt{search-publications.py}, in a similar manner as Listing~\ref{listing:start-elasticsearch-run}.
The contents of the \texttt{search\_publications.py} script are given in Listing~\ref{listing:search_publications.py}. This Python script opens a connection to Elasticsearch, using the localhost and the port number. It then uses the \texttt{search} function to build and run a search. The response from the search is assigned to \texttt{response}. The body of the search is given within the \texttt{body} dictionary. Once the search has run the results are printed, in terms of the number of documents that are found and each of the documents that are found. The \texttt{pprint} function is used to create a formatted output that is easier to read.
The contents of the \texttt{search-publications.py} script are given in Listing~\ref{listing:search-publications.py}. This Python script opens a connection to Elasticsearch, using the localhost and the port number. It then uses the \texttt{search} function to build and run a search. The response from the search is assigned to \texttt{response}. The body of the search is given within the \texttt{body} dictionary. Once the search has run the results are printed, in terms of the number of documents that are found and each of the documents that are found. The \texttt{pprint} function is used to create a formatted output that is easier to read.
\lstinputlisting[caption={The file search\_publications.py.},label=listing:search_publications.py,language=python]{../search_publications.py}
\lstinputlisting[caption={The file search-publications.py.},label=listing:search-publications.py,language=python]{../search-publications.py}
\item Run the script \texttt{delete-index-library.sh}, in a similar manner as Listing~\ref{listing:start-elasticsearch-run} to delete all of the publications.
\item Run the script \texttt{delete-index-publications.sh}, in a similar manner as Listing~\ref{listing:start-elasticsearch-run} to delete all of the publications.
\item Run the Python script \texttt{add\_publication.py}, in a similar manner as Listing~\ref{listing:start-elasticsearch-run}. Then list the publications to confirm that a publication has been added.
\item Run the Python script \texttt{add-publication.py}, in a similar manner as Listing~\ref{listing:start-elasticsearch-run}. Then list the publications to confirm that a publication has been added.
The contents of the \texttt{add\_publication.py} script are given in Listing~\ref{listing:add_publication.py}. This Python script connects to the Elasticsearch server and attempts to create a new index, document type and document entry. The body contains the document definition.
The contents of the \texttt{add-publication.py} script are given in Listing~\ref{listing:add-publication.py}. This Python script connects to the Elasticsearch server and attempts to create a new index, document type and document entry. The body contains the document definition.
\lstinputlisting[caption={The file add\_publication.py.},label=listing:add_publication.py,language=python]{../add_publication.py}
\lstinputlisting[caption={The file add-publication.py.},label=listing:add-publication.py,language=python]{../add-publication.py}
\item Run the Python script \texttt{add\_planets.py}, in a similar manner as Listing~\ref{listing:start-elasticsearch-run}. Then run \texttt{get-planets.sh} to check that some planets have been added.
\item Run the Python script \texttt{add-planets.py}, in a similar manner as Listing~\ref{listing:start-elasticsearch-run}. Then run \texttt{get-planets.sh} to check that some planets have been added.
The contents of the \texttt{add\_planets.py} script are given in Listing~\ref{listing:add_planets.py}. The script loads the \texttt{planets.json} file into memory. Then the JSON is converted into a list of dictionaries, which is stored in the \texttt{json\_data} variable. A connection is made to the Elasticsearch server. Then each of the planets are added to Elasticsearch. The Moon is skipped, since it is not a planet. If the request to add a planet fails, it is caught at Line~30.
The contents of the \texttt{add-planets.py} script are given in Listing~\ref{listing:add-planets.py}. The script loads the \texttt{planets.json} file into memory. Then the JSON is converted into a list of dictionaries, which is stored in the \texttt{json\_data} variable. A connection is made to the Elasticsearch server. Then each of the planets are added to Elasticsearch. The Moon is skipped, since it is not a planet. If the request to add a planet fails, it is caught at Line~30.
\lstinputlisting[caption={The file add\_planets.py.},label=listing:add_planets.py,language=python]{../add_planets.py}
\lstinputlisting[caption={The file add-planets.py.},label=listing:add-planets.py,language=python]{../add-planets.py}
\item Try re-running the \texttt{add\_planets.py} script and see what happens. How many document records are present before and after \texttt{add\_planets.py} has been run? Use the example \texttt{get-author.sh} and modify the command to get one of the planet documents. Then check the version number.
\item Try re-running the \texttt{add-planets.py} script and see what happens. How many document records are present before and after \texttt{add-planets.py} has been run? Use the example \texttt{get-author.sh} and modify the command to get one of the planet documents. Then check the version number.
\end{enumerate}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment