The source code retrieval task refers to using natural language as a query statement to search for relevant code fragments in the code base. In code retrieval task, most code retrieval algorithms only consider the text sequence information of the code snippets without considering the structural information of the code, resulting in the inability to fully capture the semantic and grammatical information contained in the code snippets. In order to improve the understanding of programming languages, a code retrieval algorithm (GraphCS) based on the combination of attention mechanism and graph embedding is proposed. In the feature extraction part, LSTM is used to extract the text feature vector representation, and Graph2Vec is used to extract the graph vector feature representation. The attention mechanism is introduced in the feature fusion part to better assign corresponding weights to each feature, thereby improving the understanding of the program. Considering heterogeneous data in source code and natural language, the code fragment features and natural language features are mapped to the same vector space, and ranking loss is used to ensure that the semantically similar points have a closer distance in the feature space. In order to verify the efficiency of the algorithm, it is compared with the best algorithm CODEnn. Experimental results show that there is a certain improvement in Precision@1/5/10, SuccessRate@1/5/10 and MRR.